Class: Vapid::Template
- Defined in:
- lib/vapid/template.rb,
lib/vapid/template/node.rb,
lib/vapid/template/parser.rb
Overview
Template handler
Defined Under Namespace
Instance Method Summary collapse
-
#initialize(html) ⇒ Template
constructor
A new instance of Template.
-
#render ⇒ Object
rubocop:disable Metrics/AbcSize.
- #tree ⇒ Object
Constructor Details
Instance Method Details
#render ⇒ Object
rubocop:disable Metrics/AbcSize
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/vapid/template.rb', line 30 def render @parser = Parser.new(@html, default_group_content) @parser.walk set_context: method(:fetch_content) do |node, content| node.clone(content.size - 1) if node.cloneable? record = node.clone? ? content[node.clone_index] : content.first apply_directives(node, record) end add_development_styles if @development @parser.to_html end |
#tree ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/vapid/template.rb', line 14 def tree branches = {} @parser = Parser.new(@html, default_group) @parser.walk do |node, group_expr| branches[group_expr] ||= {} node.directives.each do |type, field| branches[group_expr][field] ||= [] branches[group_expr][field] << type end end branches end |