Module: Undies::API
- Included in:
- Template
- Defined in:
- lib/undies/api.rb
Constant Summary collapse
- SELF_CLOSING_TAGS =
HTML tag helpers
[ :area, :base, :br, :col, :embed, :frame, :hr, :img, :input, :link, :meta, :param ]
- OPEN_TAGS =
[ :a, :abbr, :acronym, :address, :article, :aside, :audio, :b, :bdo, :big, :blockquote, :body, :button, :canvas, :caption, :center, :cite, :code, :colgroup, :command, :datalist, :dd, :del, :details, :dfn, :dialog, :div, :dl, :dt, :em, :fieldset, :figure, :footer, :form, :frameset, :h1, :h2, :h3, :h4, :h5, :h6, :head, :header, :hgroup, :html, :i, :iframe, :ins, :keygen, :kbd, :label, :legend, :li, :map, :mark, :meter, :nav, :noframes, :noscript, :object, :ol, :optgroup, :option, :p, :pre, :progress, :q, :ruby, :rt, :rp, :s, :samp, :script, :section, :select, :small, :source, :span, :strike, :strong, :style, :sub, :sup, :table, :tbody, :td, :textarea, :tfoot, :th, :thead, :time, :title, :tr, :tt, :u, :ul, :v, :video ]
Instance Method Summary collapse
-
#_(data = "") ⇒ Object
Add a text node (data escaped) to the current node.
-
#__attrs(attrs_hash = {}) ⇒ Object
call this to modify element attrs inside a build block.
- #__closed_element(name, *args) ⇒ Object (also: #__closed_tag)
-
#__flush ⇒ Object
call this to manually flush a template.
- #__open_element(name, *args, &build) ⇒ Object (also: #__open_tag, #__element, #__tag)
-
#__partial(source, data = {}) ⇒ Object
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.
-
#__pop ⇒ Object
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.
-
#__push ⇒ Object
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.
-
#__yield ⇒ Object
call this to render template source use this method in layouts to insert a layout’s content source.
- #closed_element(name, *args) ⇒ Object (also: #closed_tag)
- #open_element(name, *args) ⇒ Object (also: #open_tag, #element, #tag)
-
#raw(string) ⇒ Object
capture methods.
Instance Method Details
#_(data = "") ⇒ Object
Add a text node (data escaped) to the current node
76 77 78 |
# File 'lib/undies/api.rb', line 76 def _(data="") @_undies_io.current.text(self.class.escape_html(data.to_s)) end |
#__attrs(attrs_hash = {}) ⇒ Object
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
135 136 137 |
# File 'lib/undies/api.rb', line 135 def __attrs(attrs_hash={}) @_undies_io.current.attrs(attrs_hash) end |
#__closed_element(name, *args) ⇒ Object Also known as: __closed_tag
90 91 92 93 94 95 |
# 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 |
#__flush ⇒ Object
call this to manually flush a template
127 128 129 |
# File 'lib/undies/api.rb', line 127 def __flush @_undies_io.current.flush end |
#__open_element(name, *args, &build) ⇒ Object Also known as: __open_tag, __element, __tag
80 81 82 83 84 85 |
# 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 |
#__partial(source, data = {}) ⇒ Object
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
155 156 157 158 159 160 161 |
# 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 ⇒ Object
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
122 123 124 |
# File 'lib/undies/api.rb', line 122 def __pop @_undies_io.current.pop end |
#__push ⇒ Object
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
115 116 117 |
# File 'lib/undies/api.rb', line 115 def __push @_undies_io.current.push end |
#__yield ⇒ Object
call this to render template source use this method in layouts to insert a layout’s content source
143 144 145 146 147 148 149 150 |
# 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) ⇒ Object Also known as: closed_tag
60 61 62 |
# File 'lib/undies/api.rb', line 60 def closed_element(name, *args) Element::Closed.new(name, *args) end |
#open_element(name, *args) ⇒ Object Also known as: open_tag, element, tag
53 54 55 |
# File 'lib/undies/api.rb', line 53 def open_element(name, *args) Element::Open.new(name, *args) end |
#raw(string) ⇒ Object
capture methods
49 50 51 |
# File 'lib/undies/api.rb', line 49 def raw(string) Raw.new(string) end |