A tag binding is passed into each tag definition and contains helper methods for working with tags. Use it to gain access to the attributes that were passed to the tag, to render the tag contents, and to do other tasks.
The attributes of the tag. Also aliased as #attr.
The attributes of the tag. Also aliased as #attr.
The render block. When called expands the contents of the tag. Use #expand instead.
The Context that the TagBinding is associated with. Used internally. Try not to use this object directly.
The locals object for the current tag.
The name of the tag (as used in a template string).
Creates a new TagBinding object.
# File lib/radius/tag_binding.rb, line 27 def initialize(context, locals, name, attributes, block) @context, @locals, @name, @attributes, @block = context, locals, name, attributes, block end
Shortcut for accessing tag.attr
# File lib/radius/tag_binding.rb, line 67 def [](key) attr[key] end
Returns true if the current tag is a container tag.
# File lib/radius/tag_binding.rb, line 42 def double? not single? end
Evaluates the current tag and returns the rendered contents.
# File lib/radius/tag_binding.rb, line 32 def expand double? ? block.call : '' end
The globals object from which all locals objects ultimately inherit their values.
# File lib/radius/tag_binding.rb, line 47 def globals @context.globals end
Fires off Radius::Context#tag_missing for the current tag.
# File lib/radius/tag_binding.rb, line 57 def missing! @context.tag_missing(name, attributes, &block) end
Returns a list of the way tags are nested around the current tag as a string.
# File lib/radius/tag_binding.rb, line 52 def nesting @context.current_nesting end
Renders the tag using the current context .
# File lib/radius/tag_binding.rb, line 62 def render(tag, attributes = {}, &block) @context.render_tag(tag, attributes, &block) end
Returns true if the current tag is a single tag.
# File lib/radius/tag_binding.rb, line 37 def single? block.nil? end