Class: ExpressTemplates::Components::NullWrap
- Defined in:
- lib/express_templates/components/null_wrap.rb
Overview
NullWrap is useful for creating a node in the component tree that does not produce any markup. It can be used in a template fragment to wrap bare text or string content where such would not normally be possible.
Example:
“‘ruby div {
some_component
null_wrap {
"Some text"
}
other_component
} “‘
Otherwise you can use it to hold already-complied code meant for evaluation in the view that needs to be protected from being compiled again. This use is largely internal to express_templates. It is not expected that users of this library would need this.
Example:
“‘ruby null_wrap(“(@collection.map do |member| "<li>#membermember.name</li>").join”) “`
Instance Attribute Summary
Attributes inherited from Expander
#handlers, #locals, #stack, #template
Instance Method Summary collapse
- #compile ⇒ Object
-
#initialize(*args) ⇒ NullWrap
constructor
A new instance of NullWrap.
Methods included from Capabilities::Parenting
Methods inherited from Base
Methods included from Capabilities::Iterating
Methods included from Capabilities::Wrapping
Methods included from Capabilities::Rendering
Methods included from Capabilities::Templating
Methods included from Macro
Methods inherited from Expander
#expand, #initialize_expander, #method_missing, #process_children!, register_macros_for
Constructor Details
#initialize(*args) ⇒ NullWrap
Returns a new instance of NullWrap.
31 32 33 34 |
# File 'lib/express_templates/components/null_wrap.rb', line 31 def initialize(*args) @already_compiled_stuff = args.shift if args.first.is_a?(String) super(*args) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ExpressTemplates::Expander
Instance Method Details
#compile ⇒ Object
36 37 38 |
# File 'lib/express_templates/components/null_wrap.rb', line 36 def compile @already_compiled_stuff || compile_children end |