0
@@ -12,68 +12,79 @@ module ActionView # :nodoc:
0
- # Markaby helpers for Rails.
0
- module ActionControllerHelpers
0
- # Returns a string of HTML built from the attached +block+. Any +options+ are
0
- # passed into the render method.
0
- # Use this method in your controllers to output Markaby directly from inside.
0
- def render_markaby(options = {}, &block)
0
- render options.merge({ :text => Builder.new(options[:locals], self, &block).to_s })
0
+ # Markaby helpers for Rails.
0
+ module ActionControllerHelpers
0
+ # Returns a string of HTML built from the attached +block+. Any +options+ are
0
+ # passed into the render method.
0
+ # Use this method in your controllers to output Markaby directly from inside.
0
+ def render_markaby(options = {}, &block)
0
+ render options.merge({ :text => Builder.new(options[:locals], self, &block).to_s })
0
- class ActionViewTemplateHandler # :nodoc:
0
- def initialize(action_view)
0
- @action_view = action_view
0
- def render(template, local_assigns, file_path)
0
- template = Template.new(template)
0
- template.path = file_path
0
- template.render(@action_view.assigns.merge(local_assigns), @action_view)
0
+ class ActionViewTemplateHandler # :nodoc:
0
+ def initialize(action_view)
0
+ @action_view = action_view
0
+ def render(template, local_assigns, file_path)
0
+ template = Template.new(template)
0
+ template.path = file_path
0
+ template.render(@action_view.assigns.merge(local_assigns), @action_view)
0
+ class Builder < Markaby::Builder # :nodoc:
0
+ def initialize(*args, &block)
0
+ @assigns.each { |k, v| @helpers.instance_variable_set("@#{k}", v) }
0
+ @helpers.controller.send(:flash, *args)
0
+ # Emulate ERB to satisfy helpers like <tt>form_for</tt>.
0
+ @_erbout ||= FauxErbout.new(self)
0
- class FauxErbout < ::Builder::BlankSlate # :nodoc:
0
- def initialize(builder)
0
- def nil? # see ActionView::Helpers::CaptureHelper#capture
0
- def method_missing(*args, &block)
0
- @builder.send *args, &block
0
- class Builder # :nodoc:
0
- @helpers.controller.send(:flash, *args)
0
+ # Content_for will store the given block in an instance variable for later use
0
+ # in another template or in the layout.
0
+ # The name of the instance variable is content_for_<name> to stay consistent
0
+ # with @content_for_layout which is used by ActionView's layouts.
0
+ # content_for("header") do
0
+ # h1 "Half Shark and Half Lion"
0
+ # If used several times, the variable will contain all the parts concatenated.
0
+ def content_for(name, &block)
0
+ @helpers.assigns["content_for_#{name}"] =
0
+ eval("@content_for_#{name} = (@content_for_#{name} || '') + capture(&block)")
0
- # Emulate ERB to satisfy helpers like <tt>form_for</tt>.
0
- @_erbout ||= FauxErbout.new(self)
0
+ Template.builder_class = Builder
0
+ class FauxErbout < ::Builder::BlankSlate # :nodoc:
0
+ def initialize(builder)
0
+ def nil? # see ActionView::Helpers::CaptureHelper#capture
0
+ def method_missing(*args, &block)
0
+ @builder.send *args, &block
0
- # Content_for will store the given block in an instance variable for later use
0
- # in another template or in the layout.
0
- # The name of the instance variable is content_for_<name> to stay consistent
0
- # with @content_for_layout which is used by ActionView's layouts.
0
- # content_for("header") do
0
- # h1 "Half Shark and Half Lion"
0
- # If used several times, the variable will contain all the parts concatenated.
0
- def content_for(name, &block)
0
- @helpers.assigns["content_for_#{name}"] =
0
- eval("@content_for_#{name} = (@content_for_#{name} || '') + capture(&block)")
Comments
No one has commented yet.