Class: Liquid::Include
- Defined in:
- lib/liquid/tags/include.rb,
lib/liquid/profiler/hooks.rb
Overview
Include allows templates to relate with other templates
Simply include another template:
{% include 'product' %}
Include a template with a local variable:
{% include 'product' with products[0] %}
Include a template for a collection:
{% include 'product' for products %}
Constant Summary collapse
- Syntax =
/(#{QuotedFragment}+)(\s+(?:with|for)\s+(#{QuotedFragment}+))?/o
Instance Attribute Summary
Attributes inherited from Tag
#line_number, #nodelist, #options, #warnings
Instance Method Summary collapse
-
#initialize(tag_name, markup, options) ⇒ Include
constructor
A new instance of Include.
- #parse(tokens) ⇒ Object
- #render_with_profiling(context) ⇒ Object (also: #render)
Methods inherited from Tag
Methods included from ParserSwitching
Constructor Details
#initialize(tag_name, markup, options) ⇒ Include
Returns a new instance of Include.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/liquid/tags/include.rb', line 20 def initialize(tag_name, markup, ) super if markup =~ Syntax @template_name = $1 @variable_name = $3 @attributes = {} markup.scan(TagAttributes) do |key, value| @attributes[key] = value end else raise SyntaxError.new([:locale].t("errors.syntax.include".freeze)) end end |
Instance Method Details
#parse(tokens) ⇒ Object
38 39 |
# File 'lib/liquid/tags/include.rb', line 38 def parse(tokens) end |
#render_with_profiling(context) ⇒ Object Also known as: render
14 15 16 17 18 |
# File 'lib/liquid/profiler/hooks.rb', line 14 def render_with_profiling(context) Profiler.profile_children(@template_name) do render_without_profiling(context) end end |