Class: Fortitude::Tilt::FortitudeTemplate
- Inherits:
-
Tilt::Template
- Object
- Tilt::Template
- Fortitude::Tilt::FortitudeTemplate
- Defined in:
- lib/fortitude/tilt/fortitude_template.rb
Instance Method Summary collapse
Instance Method Details
#prepare ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fortitude/tilt/fortitude_template.rb', line 9 def prepare if file && line ::Object.class_eval(data, file, line) else ::Object.class_eval(data) end # 2014-06-19 ageweke -- Earlier versions of Tilt try to instantiate the engine with an empty tempate as a way # of making sure it can be created, so we have to support this case. if data.strip.length > 0 @fortitude_class = ::Fortitude::Widget.( data, :magic_comment_text => 'fortitude_tilt_class', :class_names_to_try => Array([:fortitude_class]) + Array([:class_names_to_try])) end end |
#render(scope = Object.new, locals = nil, &block) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fortitude/tilt/fortitude_template.rb', line 26 def render(scope=Object.new, locals = nil, &block) locals ||= { } rendering_context = Fortitude::RenderingContext.new({ :yield_block => block, :render_yield_result => false, :helpers_object => scope, :instance_variables_object => scope }) = { } scope.instance_variables.each do |instance_variable_name| if instance_variable_name.to_s =~ /^\@(.*)$/ [$1] = scope.instance_variable_get(instance_variable_name) end end = .merge(locals) = fortitude_class.extract_needed_assigns_from() unless fortitude_class.extra_assigns == :use = fortitude_class.new() .render_to(rendering_context) rendering_context.output_buffer_holder.output_buffer end |