diff --git a/lib/liquid/variable.rb b/lib/liquid/variable.rb index 7710cef..5e18710 100644 --- a/lib/liquid/variable.rb +++ b/lib/liquid/variable.rb @@ -83,7 +83,6 @@ module Liquid end def render(context) - return ''.freeze if @name.nil? @filters.inject(context.evaluate(@name)) do |output, (filter_name, filter_args, filter_kwargs)| filter_args = evaluate_filter_expressions(context, filter_args, filter_kwargs) output = context.invoke(filter_name, output, *filter_args) diff --git a/test/integration/tags/if_else_tag_test.rb b/test/integration/tags/if_else_tag_test.rb index 2613835..3e1797e 100644 --- a/test/integration/tags/if_else_tag_test.rb +++ b/test/integration/tags/if_else_tag_test.rb @@ -8,7 +8,11 @@ class IfElseTagTest < Minitest::Test assert_template_result(' this text should go into the output ', ' {% if true %} this text should go into the output {% endif %} ') assert_template_result(' you rock ?','{% if false %} you suck {% endif %} {% if true %} you rock {% endif %}?') + end + + def test_literal_comparisons assert_template_result(' NO ','{% assign v = false %}{% if v %} YES {% else %} NO {% endif %}') + assert_template_result(' YES ','{% assign v = nil %}{% if v == nil %} YES {% else %} NO {% endif %}') end def test_if_else diff --git a/test/integration/variable_test.rb b/test/integration/variable_test.rb index a7dc1e1..4d08cf4 100644 --- a/test/integration/variable_test.rb +++ b/test/integration/variable_test.rb @@ -34,6 +34,10 @@ class VariableTest < Minitest::Test assert_equal 'false', Template.parse("{{ false }}").render! end + def test_nil_operations + assert_equal 'cat', Template.parse("{{ nil | append: 'cat' }}").render! + end + def test_preset_assigns template = Template.parse(%|{{ test }}|) template.assigns['test'] = 'worked'