Class: Flame::Render
- Inherits:
-
Object
- Object
- Flame::Render
- Defined in:
- lib/flame/render.rb
Overview
Helper for render functionality
Class Method Summary collapse
-
.tilts ⇒ Object
private.
Instance Method Summary collapse
-
#initialize(ctrl, path, options = {}) ⇒ Render
constructor
A new instance of Render.
-
#render(cache: true) ⇒ Object
Render template.
Constructor Details
#initialize(ctrl, path, options = {}) ⇒ Render
Returns a new instance of Render.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/flame/render.rb', line 12 def initialize(ctrl, path, = {}) ## Take options for rendering @ctrl = ctrl @scope = .delete(:scope) || @ctrl @layout = .delete(:layout) @layout = 'layout.*' if @layout.nil? ## And get the rest variables to locals @locals = .merge(.delete(:locals) || {}) ## Find filename @filename = find_file(path) # @ctrl.instance_exec { halt 404 } unless @filename return unless @filename @layout = nil if File.basename(@filename)[0] == '_' end |
Class Method Details
.tilts ⇒ Object
private
43 44 45 |
# File 'lib/flame/render.rb', line 43 def tilts @tilts ||= {} end |
Instance Method Details
#render(cache: true) ⇒ Object
Render template
29 30 31 32 33 34 35 36 |
# File 'lib/flame/render.rb', line 29 def render(cache: true) @cache = cache ## Compile Tilt to instance hash return unless @filename tilt = compile_file ## Render Tilt from instance hash with new options layout_render tilt.render(@scope, @locals) end |