Class: Markaby::Rails::Builder
- Defined in:
- lib/markaby/rails/deprecated.rb
Overview
:nodoc:
Constant Summary
Constants inherited from Builder
Instance Attribute Summary
Attributes inherited from Builder
Instance Method Summary collapse
-
#_erbout ⇒ Object
Emulate ERB to satisfy helpers like
form_for
. -
#content_for(name, &block) ⇒ Object
Content_for will store the given block in an instance variable for later use in another template or in the layout.
- #flash(*args) ⇒ Object
-
#initialize(*args, &block) ⇒ Builder
constructor
A new instance of Builder.
Methods inherited from Builder
#capture, get, #helper=, ignore_helpers, ignored_helpers, #locals=, restore_defaults!, set, #tag!, #text, #to_s
Methods included from BuilderTags
#head, #html_tag, #xhtml_frameset, #xhtml_strict, #xhtml_transitional
Constructor Details
#initialize(*args, &block) ⇒ Builder
Returns a new instance of Builder.
68 69 70 71 72 |
# File 'lib/markaby/rails/deprecated.rb', line 68 def initialize(*args, &block) super *args, &block @assigns.each { |k, v| @helpers.instance_variable_set("@#{k}", v) } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Markaby::Builder
Instance Method Details
#_erbout ⇒ Object
Emulate ERB to satisfy helpers like form_for
.
79 80 81 |
# File 'lib/markaby/rails/deprecated.rb', line 79 def _erbout @_erbout ||= FauxErbout.new(self) end |
#content_for(name, &block) ⇒ Object
Content_for will store the given block in an instance variable for later use in another template or in the layout.
The name of the instance variable is content_for_<name> to stay consistent with @content_for_layout which is used by ActionView’s layouts.
Example:
content_for("header") do
h1 "Half Shark and Half Lion"
end
If used several times, the variable will contain all the parts concatenated.
96 97 98 99 |
# File 'lib/markaby/rails/deprecated.rb', line 96 def content_for(name, &block) @helpers.assigns["content_for_#{name}"] = eval("@content_for_#{name} = (@content_for_#{name} || '') + capture(&block)") end |
#flash(*args) ⇒ Object
74 75 76 |
# File 'lib/markaby/rails/deprecated.rb', line 74 def flash(*args) @helpers.controller.send(:flash, *args) end |