Class: Rack::Component::Renderer
- Inherits:
-
Object
- Object
- Rack::Component::Renderer
- Defined in:
- lib/rack/component/renderer.rb
Overview
Compile a Tilt template, which a component will render
Constant Summary collapse
- DEFAULT_TILT_OPTIONS =
{ escape_html: true }.freeze
- FORMATS =
i[erb rhtml erubis haml liquid markdown md mkd].freeze
Instance Method Summary collapse
- #call(scope, &child) ⇒ Object
-
#initialize(options = {}) ⇒ Renderer
constructor
A new instance of Renderer.
Constructor Details
#initialize(options = {}) ⇒ Renderer
Returns a new instance of Renderer.
8 9 10 11 12 13 |
# File 'lib/rack/component/renderer.rb', line 8 def initialize( = {}) require 'tilt' engine, template, @config = OptionParser.call() require 'erubi' if engine == 'erb' && @config[:escape_html] @template = Tilt[engine].new(@config) { template } end |
Instance Method Details
#call(scope, &child) ⇒ Object
15 16 17 |
# File 'lib/rack/component/renderer.rb', line 15 def call(scope, &child) @template.render(scope, &child) end |