module Undies::API
Constants
- OPEN_TAGS
- SELF_CLOSING_TAGS
HTML tag helpers
Public Instance Methods
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
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
# 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
call this to manually flush a template
# File lib/undies/api.rb, line 127 def __flush @_undies_io.current.flush end
# 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
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
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
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
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
# File lib/undies/api.rb, line 60 def closed_element(name, *args) Element::Closed.new(name, *args) end
# File lib/undies/api.rb, line 53 def open_element(name, *args) Element::Open.new(name, *args) end
capture methods
# File lib/undies/api.rb, line 49 def raw(string) Raw.new(string) end