mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-16 09:20:42 -07:00
Remove mutable render state from Liquid::Template
Use Liquid::Context to access this mutable state after rendering or to have state that is persisted between mutations
This commit is contained in:
@@ -51,29 +51,10 @@ class VariableTest < Minitest::Test
|
||||
assert_equal('cat', Template.parse("{{ nil | append: 'cat' }}").render!)
|
||||
end
|
||||
|
||||
def test_preset_assigns
|
||||
template = Template.parse(%({{ test }}))
|
||||
template.assigns['test'] = 'worked'
|
||||
assert_equal('worked', template.render!)
|
||||
end
|
||||
|
||||
def test_reuse_parsed_template
|
||||
template = Template.parse(%({{ greeting }} {{ name }}))
|
||||
template.assigns['greeting'] = 'Goodbye'
|
||||
template = Template.parse(%({{ greeting }} {{ name }}))
|
||||
assert_equal('Hello Tobi', template.render!('greeting' => 'Hello', 'name' => 'Tobi'))
|
||||
assert_equal('Hello ', template.render!('greeting' => 'Hello', 'unknown' => 'Tobi'))
|
||||
assert_equal('Hello Brian', template.render!('greeting' => 'Hello', 'name' => 'Brian'))
|
||||
assert_equal('Goodbye Brian', template.render!('name' => 'Brian'))
|
||||
assert_equal({ 'greeting' => 'Goodbye' }, template.assigns)
|
||||
end
|
||||
|
||||
def test_assigns_not_polluted_from_template
|
||||
template = Template.parse(%({{ test }}{% assign test = 'bar' %}{{ test }}))
|
||||
template.assigns['test'] = 'baz'
|
||||
assert_equal('bazbar', template.render!)
|
||||
assert_equal('bazbar', template.render!)
|
||||
assert_equal('foobar', template.render!('test' => 'foo'))
|
||||
assert_equal('bazbar', template.render!)
|
||||
assert_equal('Goodbye Brian', template.render!('greeting' => 'Goodbye', 'name' => 'Brian'))
|
||||
end
|
||||
|
||||
def test_hash_with_default_proc
|
||||
|
||||
Reference in New Issue
Block a user