Class: ExpressTemplates::Components::NullWrap

Inherits:
Container show all
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

Methods included from Capabilities::Parenting

included

Methods inherited from Base

inherited

Methods included from Capabilities::Iterating

included

Methods included from Capabilities::Wrapping

included

Methods included from Capabilities::Rendering

included

Methods included from Capabilities::Templating

included

Methods included from Macro

included

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

#compileObject



36
37
38
# File 'lib/express_templates/components/null_wrap.rb', line 36

def compile
  @already_compiled_stuff || compile_children
end