Class: Markaby::Rails::TemplateHandler
- Inherits:
-
ActionView::TemplateHandler
- Object
- ActionView::TemplateHandler
- Markaby::Rails::TemplateHandler
- Includes:
- ActionView::TemplateHandlers::Compilable
- Defined in:
- lib/markaby/rails/current.rb
Instance Attribute Summary collapse
-
#view ⇒ Object
Returns the value of attribute view.
Instance Method Summary collapse
- #compile(template, local_assigns = {}) ⇒ Object
- #render(template, local_assigns = (template.respond_to?(:locals) ? template.locals : {})) ⇒ Object
Instance Attribute Details
#view ⇒ Object
Returns the value of attribute view.
27 28 29 |
# File 'lib/markaby/rails/current.rb', line 27 def view @view end |
Instance Method Details
#compile(template, local_assigns = {}) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/markaby/rails/current.rb', line 8 def compile(template, local_assigns={}) <<-CODE handler = Markaby::Rails::TemplateHandler.new handler.view = self handler.render(lambda { #{template.source} }, local_assigns) CODE end |
#render(template, local_assigns = (template.respond_to?(:locals) ? template.locals : {})) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/markaby/rails/current.rb', line 16 def render(template, local_assigns = (template.respond_to?(:locals) ? template.locals : {})) builder = RailsBuilder.new(instance_variables.merge(local_assigns), @view) @view.output_buffer = builder template.is_a?(Proc) ? builder.instance_eval(&template) : builder.instance_eval(template.source) builder.to_s end |