class Radius::TagBinding

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.

Attributes

attr[R]

The attributes of the tag. Also aliased as TagBinding#attr.

attributes[R]

The attributes of the tag. Also aliased as TagBinding#attr.

block[R]

The render block. When called expands the contents of the tag. Use TagBinding#expand instead.

context[R]

The Context that the TagBinding is associated with. Used internally. Try not to use this object directly.

locals[R]

The locals object for the current tag.

name[R]

The name of the tag (as used in a template string).

Public Class Methods

new(context, locals, name, attributes, block) click to toggle source

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

Public Instance Methods

[](key) click to toggle source

Shortcut for accessing tag.attr

# File lib/radius/tag_binding.rb, line 67
def [](key)
  attr[key]
end
double?() click to toggle source

Returns true if the current tag is a container tag.

# File lib/radius/tag_binding.rb, line 42
def double?
  not single?
end
expand() click to toggle source

Evaluates the current tag and returns the rendered contents.

# File lib/radius/tag_binding.rb, line 32
def expand
  double? ? block.call : ''
end
globals() click to toggle source

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
missing!() click to toggle source

Fires off Context#tag_missing for the current tag.

# File lib/radius/tag_binding.rb, line 57
def missing!
  @context.tag_missing(name, attributes, &block)
end
nesting() click to toggle source

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
render(tag, attributes = {}, &block) click to toggle source

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
single?() click to toggle source

Returns true if the current tag is a single tag.

# File lib/radius/tag_binding.rb, line 37
def single?
  block.nil?
end