Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

action_view_preview

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

action_view_preview

  • 0.1.5
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

ActionViewPreview

Sometimes being able to preview a view might come in handy, like when a view is going to be used only inside a PDF, for example.

This gem allows a setup similar ActionMailer::Preview, and provides a development tool for rendering and debugging views that wouldn't otherwise be rendered in your application.

Installation

Add this line to your application's Gemfile:

gem 'action_view_preview'

And then execute:

$ bundle

Or install it yourself as:

$ gem install action_view_preview

Usage

Command Line Install

Run rails generate action_view_preview:install and the generator should create a hello_preview.rb and mount the route in your routes.rb file, similar to the steps shown below in the manual install.

Manual Install

  1. Mount the engine in your routes.rb:
Rails.application.routes.draw do
  # Add the line below
  mount ActionViewPreview::Engine => "/action_view_preview"
end
  1. Create files *_preview.rb on test/views/previews/, e.g. hello_preview.rb:
class HelloViewPreview < ActionViewPreview::Base
  def hello
    '<b>Hello world</b>'
  end
end
  1. Access the route /action_view_preview to see the available previews

Configuration

Add a ActionViewPreview.setup block to an initializer. For example, if you want to place the preview files in lib/view_previews:

ActionViewPreview.setup do |config|
  config.preview_path = "#{Rails.root}/lib/view_previews"
end

Possible config values:

ConfigDefaultDescription
preview_pathtest/views/previewsPath to the preview files

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 10 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc