Class: LiquidXlsx::Validation::LiquidUsage
- Inherits:
-
Object
- Object
- LiquidXlsx::Validation::LiquidUsage
- Defined in:
- lib/liquid_xlsx/validation/liquid_usage.rb
Overview
Walks a parsed Liquid template and collects what it refers to: variable paths, filter names, and the names it binds itself.
The point of doing this here rather than in the host application is that
the host would have to parse every fragment a second time — and parse it
with this gem's Liquid environment, or {% sheet %} and {% image_tag %}
would come back as unknown tags. Handing back extracted usages keeps
Liquid entirely on this side of the boundary.
Instance Attribute Summary collapse
-
#assigns ⇒ Object
readonly
Returns the value of attribute assigns.
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
-
#locals ⇒ Object
readonly
Returns the value of attribute locals.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Class Method Summary collapse
-
.call(root) ⇒ Object
Tags whose bodies Liquid exposes through an attachment rather than a nodelist (case % branches).
Instance Method Summary collapse
-
#initialize ⇒ LiquidUsage
constructor
A new instance of LiquidUsage.
- #walk(node) ⇒ Object
Constructor Details
#initialize ⇒ LiquidUsage
Returns a new instance of LiquidUsage.
24 25 26 27 28 29 |
# File 'lib/liquid_xlsx/validation/liquid_usage.rb', line 24 def initialize @variables = [] @filters = [] @assigns = [] @locals = [] end |
Instance Attribute Details
#assigns ⇒ Object (readonly)
Returns the value of attribute assigns.
22 23 24 |
# File 'lib/liquid_xlsx/validation/liquid_usage.rb', line 22 def assigns @assigns end |
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
22 23 24 |
# File 'lib/liquid_xlsx/validation/liquid_usage.rb', line 22 def filters @filters end |
#locals ⇒ Object (readonly)
Returns the value of attribute locals.
22 23 24 |
# File 'lib/liquid_xlsx/validation/liquid_usage.rb', line 22 def locals @locals end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
22 23 24 |
# File 'lib/liquid_xlsx/validation/liquid_usage.rb', line 22 def variables @variables end |
Class Method Details
Instance Method Details
#walk(node) ⇒ Object
31 32 33 34 |
# File 'lib/liquid_xlsx/validation/liquid_usage.rb', line 31 def walk(node) visit(node) each_child(node) { |child| walk(child) } end |