Class: Treetop::Runtime::TemplateNode
- Inherits:
-
SyntaxNode
- Object
- SyntaxNode
- Treetop::Runtime::TemplateNode
- Defined in:
- lib/alongslide/treetop/parser.rb
Overview
Template node base class. Covers panels, panel templates, sections.
Direct Known Subclasses
Instance Method Summary collapse
-
#is_user_template ⇒ Object
Default.
-
#render ⇒ Object
Load template and render it, with content, if applicable.
-
#render_params ⇒ Object
Sections and panels optionally implement generic “class_params”, as well as required identifier.
-
#template_content ⇒ Object
If Node has “contents”, prepare content for template’s variable of the same name.
-
#template_name ⇒ Object
Template named in directive is what to look for in filesystem.
Instance Method Details
#is_user_template ⇒ Object
Default.
90 91 92 |
# File 'lib/alongslide/treetop/parser.rb', line 90 def is_user_template false end |
#render ⇒ Object
Load template and render it, with content, if applicable.
41 42 43 |
# File 'lib/alongslide/treetop/parser.rb', line 41 def render ::Alongslide::Templates::render_template template_name, is_user_template, render_params end |
#render_params ⇒ Object
Sections and panels optionally implement generic “class_params”, as well as required identifier.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/alongslide/treetop/parser.rb', line 48 def render_params params = {content: template_content || []} classes = if respond_to? :class_params class_params.elements.map do |item| item.param.text_value end end params[:classes] = (classes || []).join(" ") if respond_to? :identifier params[:identifier] = identifier.text_value end return params end |
#template_content ⇒ Object
If Node has “contents”, prepare content for template’s variable of the same name.
This may mean rendering another subtemplate, or simply some Markdown.
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/alongslide/treetop/parser.rb', line 76 def template_content if respond_to? :contents and contents contents.elements.map do |item| if item.content.respond_to? :template item.content.template.renderable.template.render else ::Alongslide::render item.text_value, plain: true end end end end |
#template_name ⇒ Object
Template named in directive is what to look for in filesystem.
67 68 69 |
# File 'lib/alongslide/treetop/parser.rb', line 67 def template_name command.text_value end |