module Undies::API

Constants

OPEN_TAGS
SELF_CLOSING_TAGS

HTML tag helpers

Public Instance Methods

_(data="") click to toggle source

Add a text node (data escaped) to the current node

# File lib/undies/api.rb, line 76
def _(data="")
  @_undies_io.current.text(self.class.escape_html(data.to_s))
end
__attrs(attrs_hash={}) click to toggle source

call this to modify element attrs inside a build block. Once content or child elements have been added, any '__attr' directives will be ignored b/c the elements start_tag has already been flushed to the output

# File lib/undies/api.rb, line 135
def __attrs(attrs_hash={})
  @_undies_io.current.attrs(attrs_hash)
end
__closed_element(name, *args) click to toggle source
# File lib/undies/api.rb, line 90
def __closed_element(name, *args)
  @_undies_io.
    current.
    element_node(ElementNode.new(@_undies_io, Element::Closed.new(name, *args))).
    element
end
Also aliased as: __closed_tag
__closed_tag(name, *args)
Alias for: __closed_element
__element(name, *args, &build)
Alias for: __open_element
__flush() click to toggle source

call this to manually flush a template

# File lib/undies/api.rb, line 127
def __flush
  @_undies_io.current.flush
end
__open_element(name, *args, &build) click to toggle source
# File lib/undies/api.rb, line 80
def __open_element(name, *args, &build)
  @_undies_io.
    current.
    element_node(ElementNode.new(@_undies_io, Element::Open.new(name, *args, &build))).
    element
end
Also aliased as: __open_tag, __element, __tag
__open_tag(name, *args, &build)
Alias for: __open_element
__partial(source, data={}) click to toggle source

call this to render partial source embedded in a template partial source is rendered with its own scope/data but shares its parent template's output object

# File lib/undies/api.rb, line 155
def __partial(source, data={})
  if source.kind_of?(Source)
    Undies::Template.new(source, data, @_undies_io)
  else
    @_undies_io.current.partial(source.to_s)
  end
end
__pop() click to toggle source

call this method to manually pop the current scope to the previous scope

  • changes the context of template method calls to operate on the parent element or root node

# File lib/undies/api.rb, line 122
def __pop
  @_undies_io.current.pop
end
__push() click to toggle source

call this method to manually push the current scope to the previously cached element (if any)

  • changes the context of template method calls to operate on that element

# File lib/undies/api.rb, line 115
def __push
  @_undies_io.current.push
end
__tag(name, *args, &build)
Alias for: __open_element
__yield() click to toggle source

call this to render template source use this method in layouts to insert a layout's content source

# File lib/undies/api.rb, line 143
def __yield
  return if (source = @_undies_source_stack.pop).nil?
  if source.file?
    instance_eval(source.data, source.source, 1)
  else
    instance_eval(&source.data)
  end
end
closed_element(name, *args) click to toggle source
# File lib/undies/api.rb, line 60
def closed_element(name, *args)
  Element::Closed.new(name, *args)
end
Also aliased as: closed_tag
closed_tag(name, *args)
Alias for: closed_element
element(name, *args)
Alias for: open_element
open_element(name, *args) click to toggle source
# File lib/undies/api.rb, line 53
def open_element(name, *args)
  Element::Open.new(name, *args)
end
Also aliased as: open_tag, element, tag
open_tag(name, *args)
Alias for: open_element
raw(string) click to toggle source

capture methods

# File lib/undies/api.rb, line 49
def raw(string)
  Raw.new(string)
end
tag(name, *args)
Alias for: open_element