mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-15 08:50:45 -07:00
Expose name, lookups, and command flags from VariableLookup
This commit is contained in:
@@ -3,6 +3,8 @@ module Liquid
|
|||||||
SQUARE_BRACKETED = /\A\[(.*)\]\z/m
|
SQUARE_BRACKETED = /\A\[(.*)\]\z/m
|
||||||
COMMAND_METHODS = ['size'.freeze, 'first'.freeze, 'last'.freeze]
|
COMMAND_METHODS = ['size'.freeze, 'first'.freeze, 'last'.freeze]
|
||||||
|
|
||||||
|
attr_reader :name, :lookups, :command_flags
|
||||||
|
|
||||||
def self.parse(markup)
|
def self.parse(markup)
|
||||||
new(markup)
|
new(markup)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -147,4 +147,16 @@ class VariableUnitTest < Minitest::Test
|
|||||||
var = Variable.new(%! name_of_variable | upcase !)
|
var = Variable.new(%! name_of_variable | upcase !)
|
||||||
assert_equal " name_of_variable | upcase ", var.raw
|
assert_equal " name_of_variable | upcase ", var.raw
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_variable_lookup_interface
|
||||||
|
lookup = VariableLookup.new('a.b.c')
|
||||||
|
assert_equal 'a', lookup.name
|
||||||
|
assert_equal ['b', 'c'], lookup.lookups
|
||||||
|
assert_equal 0, lookup.command_flags
|
||||||
|
|
||||||
|
lookup = VariableLookup.new('a.first.size')
|
||||||
|
assert_equal 'a', lookup.name
|
||||||
|
assert_equal ['first', 'size'], lookup.lookups
|
||||||
|
assert_equal 0b11, lookup.command_flags
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user