mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
Compare commits
35
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5b36665e6 | ||
|
|
9bb7fbf123 | ||
|
|
8555fd8a20 | ||
|
|
9bd408f5d0 | ||
|
|
79b831d96c | ||
|
|
aebd75e5e8 | ||
|
|
7f2f8a226b | ||
|
|
7b2b25fda1 | ||
|
|
8548b96a97 | ||
|
|
fc96e66e14 | ||
|
|
79a771d724 | ||
|
|
65b1dedac5 | ||
|
|
f375d7b3aa | ||
|
|
c6f05eaf83 | ||
|
|
eabbd5cb6f | ||
|
|
6b3f6c6fb4 | ||
|
|
ea864f1177 | ||
|
|
c34dd812c5 | ||
|
|
cc04892e54 | ||
|
|
f676e699a4 | ||
|
|
fc0f7f44c1 | ||
|
|
b459eb656f | ||
|
|
c6dcf3e714 | ||
|
|
4dae678c63 | ||
|
|
4c07ff920b | ||
|
|
dbe709c3bf | ||
|
|
2b75bfaff4 | ||
|
|
87bc6e7cfa | ||
|
|
7f122aeed2 | ||
|
|
aa1640035f | ||
|
|
f5d6a36574 | ||
|
|
c5711c095f | ||
|
|
284f5fb647 | ||
|
|
21432928d0 | ||
|
|
1783c0c084 |
@@ -0,0 +1,6 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: github-actions
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: weekly
|
||||
@@ -31,8 +31,8 @@ jobs:
|
||||
- { ruby: ruby-head, allowed-failure: false, rubyopt: "--yjit" }
|
||||
name: Test Ruby ${{ matrix.entry.ruby }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ruby/setup-ruby@v1
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
- uses: ruby/setup-ruby@dffc446db9ba5a0c4446edb5bca1c5c473a806c5 # v1.235.0
|
||||
with:
|
||||
ruby-version: ${{ matrix.entry.ruby }}
|
||||
bundler-cache: true
|
||||
@@ -45,8 +45,8 @@ jobs:
|
||||
memory_profile:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ruby/setup-ruby@v1
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
- uses: ruby/setup-ruby@dffc446db9ba5a0c4446edb5bca1c5c473a806c5 # v1.235.0
|
||||
with:
|
||||
bundler-cache: true
|
||||
- run: bundle exec rake memory_profile:run
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
# Liquid Change Log
|
||||
|
||||
## 5.8.1 (unreleased)
|
||||
## 5.8.7
|
||||
* Expose body content in the `Doc` tag [James Meng]
|
||||
|
||||
## 5.8.1
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
require 'cgi'
|
||||
require 'base64'
|
||||
require 'bigdecimal'
|
||||
|
||||
module Liquid
|
||||
module StandardFilters
|
||||
MAX_I32 = (1 << 31) - 1
|
||||
@@ -712,7 +711,16 @@ module Liquid
|
||||
input.gsub(/\r?\n/, "<br />\n")
|
||||
end
|
||||
|
||||
# Reformat a date using Ruby's core Time#strftime( string ) -> string
|
||||
# @liquid_public_docs
|
||||
# @liquid_type filter
|
||||
# @liquid_category date
|
||||
# @liquid_summary
|
||||
# Formats a date according to a specified format string.
|
||||
# @liquid_description
|
||||
# This filter formats a date using various format specifiers. If the format string is empty,
|
||||
# the original input is returned. If the input cannot be converted to a date, the original input is returned.
|
||||
#
|
||||
# The following format specifiers can be used:
|
||||
#
|
||||
# %a - The abbreviated weekday name (``Sun'')
|
||||
# %A - The full weekday name (``Sunday'')
|
||||
@@ -741,8 +749,8 @@ module Liquid
|
||||
# %Y - Year with century
|
||||
# %Z - Time zone name
|
||||
# %% - Literal ``%'' character
|
||||
#
|
||||
# See also: http://www.ruby-doc.org/core/Time.html#method-i-strftime
|
||||
# @liquid_syntax date | date: string
|
||||
# @liquid_return [string]
|
||||
def date(input, format)
|
||||
str_format = Utils.to_s(format)
|
||||
return input if str_format.empty?
|
||||
@@ -989,7 +997,7 @@ module Liquid
|
||||
end
|
||||
|
||||
def raise_property_error(property)
|
||||
raise Liquid::ArgumentError, "cannot select the property '#{property}'"
|
||||
raise Liquid::ArgumentError, "cannot select the property '#{Utils.to_s(property)}'"
|
||||
end
|
||||
|
||||
def apply_operation(input, operand, operation)
|
||||
@@ -1061,7 +1069,10 @@ module Liquid
|
||||
end
|
||||
|
||||
def uniq(&block)
|
||||
to_a.uniq(&block)
|
||||
to_a.uniq do |item|
|
||||
item = Utils.to_liquid_value(item)
|
||||
block ? yield(item) : item
|
||||
end
|
||||
end
|
||||
|
||||
def compact
|
||||
|
||||
@@ -9,6 +9,10 @@ module Liquid
|
||||
# Creates a new variable.
|
||||
# @liquid_description
|
||||
# You can create variables of any [basic type](/docs/api/liquid/basics#types), [object](/docs/api/liquid/objects), or object property.
|
||||
#
|
||||
# > Caution:
|
||||
# > Predefined Liquid objects can be overridden by variables with the same name.
|
||||
# > To make sure that you can access all Liquid objects, make sure that your variable name doesn't match a predefined object's name.
|
||||
# @liquid_syntax
|
||||
# {% assign variable_name = value %}
|
||||
# @liquid_syntax_keyword variable_name The name of the variable being created.
|
||||
|
||||
@@ -9,6 +9,10 @@ module Liquid
|
||||
# Creates a new variable with a string value.
|
||||
# @liquid_description
|
||||
# You can create complex strings with Liquid logic and variables.
|
||||
#
|
||||
# > Caution:
|
||||
# > Predefined Liquid objects can be overridden by variables with the same name.
|
||||
# > To make sure that you can access all Liquid objects, make sure that your variable name doesn't match a predefined object's name.
|
||||
# @liquid_syntax
|
||||
# {% capture variable %}
|
||||
# value
|
||||
|
||||
@@ -7,10 +7,14 @@ module Liquid
|
||||
# @liquid_name decrement
|
||||
# @liquid_summary
|
||||
# Creates a new variable, with a default value of -1, that's decreased by 1 with each subsequent call.
|
||||
#
|
||||
# > Caution:
|
||||
# > Predefined Liquid objects can be overridden by variables with the same name.
|
||||
# > To make sure that you can access all Liquid objects, make sure that your variable name doesn't match a predefined object's name.
|
||||
# @liquid_description
|
||||
# Variables that are declared with `decrement` are unique to the [layout](/themes/architecture/layouts), [template](/themes/architecture/templates),
|
||||
# or [section](/themes/architecture/sections) file that they're created in. However, the variable is shared across
|
||||
# [snippets](/themes/architecture#snippets) included in the file.
|
||||
# [snippets](/themes/architecture/snippets) included in the file.
|
||||
#
|
||||
# Similarly, variables that are created with `decrement` are independent from those created with [`assign`](/docs/api/liquid/tags/assign)
|
||||
# and [`capture`](/docs/api/liquid/tags/capture). However, `decrement` and [`increment`](/docs/api/liquid/tags/increment) share
|
||||
|
||||
+10
-3
@@ -13,6 +13,10 @@ module Liquid
|
||||
# Liquid code inside will be parsed but not executed. This facilitates
|
||||
# tooling support for features like code completion, linting, and inline
|
||||
# documentation.
|
||||
#
|
||||
# For detailed documentation syntax and examples, see the
|
||||
# [`LiquidDoc` reference](/docs/storefronts/themes/tools/liquid-doc).
|
||||
#
|
||||
# @liquid_syntax
|
||||
# {% doc %}
|
||||
# Renders a message.
|
||||
@@ -23,7 +27,6 @@ module Liquid
|
||||
# @example
|
||||
# {% render 'message', foo: 'Hello', bar: 'World' %}
|
||||
# {% enddoc %}
|
||||
# {{ foo }}, {{ bar }}!
|
||||
class Doc < Block
|
||||
NO_UNEXPECTED_ARGS = /\A\s*\z/
|
||||
|
||||
@@ -33,6 +36,8 @@ module Liquid
|
||||
end
|
||||
|
||||
def parse(tokens)
|
||||
@body = +""
|
||||
|
||||
while (token = tokens.shift)
|
||||
tag_name = token =~ BlockBody::FullTokenPossiblyInvalid && Regexp.last_match(2)
|
||||
|
||||
@@ -40,8 +45,10 @@ module Liquid
|
||||
|
||||
if tag_name == block_delimiter
|
||||
parse_context.trim_whitespace = (token[-3] == WhitespaceControl)
|
||||
@body << Regexp.last_match(1) if Regexp.last_match(1) != ""
|
||||
return
|
||||
end
|
||||
@body << token unless token.empty?
|
||||
end
|
||||
|
||||
raise_tag_never_closed(block_name)
|
||||
@@ -52,11 +59,11 @@ module Liquid
|
||||
end
|
||||
|
||||
def blank?
|
||||
true
|
||||
@body.empty?
|
||||
end
|
||||
|
||||
def nodelist
|
||||
[]
|
||||
[@body]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -6,7 +6,7 @@ module Liquid
|
||||
# @liquid_category theme
|
||||
# @liquid_name include
|
||||
# @liquid_summary
|
||||
# Renders a [snippet](/themes/architecture#snippets).
|
||||
# Renders a [snippet](/themes/architecture/snippets).
|
||||
# @liquid_description
|
||||
# Inside the snippet, you can access and alter variables that are [created](/docs/api/liquid/tags/variable-tags) outside of the
|
||||
# snippet.
|
||||
|
||||
@@ -7,10 +7,14 @@ module Liquid
|
||||
# @liquid_name increment
|
||||
# @liquid_summary
|
||||
# Creates a new variable, with a default value of 0, that's increased by 1 with each subsequent call.
|
||||
#
|
||||
# > Caution:
|
||||
# > Predefined Liquid objects can be overridden by variables with the same name.
|
||||
# > To make sure that you can access all Liquid objects, make sure that your variable name doesn't match a predefined object's name.
|
||||
# @liquid_description
|
||||
# Variables that are declared with `increment` are unique to the [layout](/themes/architecture/layouts), [template](/themes/architecture/templates),
|
||||
# or [section](/themes/architecture/sections) file that they're created in. However, the variable is shared across
|
||||
# [snippets](/themes/architecture#snippets) included in the file.
|
||||
# [snippets](/themes/architecture/snippets) included in the file.
|
||||
#
|
||||
# Similarly, variables that are created with `increment` are independent from those created with [`assign`](/docs/api/liquid/tags/assign)
|
||||
# and [`capture`](/docs/api/liquid/tags/capture). However, `increment` and [`decrement`](/docs/api/liquid/tags/decrement) share
|
||||
|
||||
@@ -6,7 +6,7 @@ module Liquid
|
||||
# @liquid_category theme
|
||||
# @liquid_name render
|
||||
# @liquid_summary
|
||||
# Renders a [snippet](/themes/architecture#snippets) or [app block](/themes/architecture/sections/section-schema#render-app-blocks).
|
||||
# Renders a [snippet](/themes/architecture/snippets) or [app block](/themes/architecture/sections/section-schema#render-app-blocks).
|
||||
# @liquid_description
|
||||
# Inside snippets and app blocks, you can't directly access variables that are [created](/docs/api/liquid/tags/variable-tags) outside
|
||||
# of the snippet or app block. However, you can [specify variables as parameters](/docs/api/liquid/tags/render#render-passing-variables-to-a-snippet)
|
||||
|
||||
+5
-2
@@ -2,6 +2,9 @@
|
||||
|
||||
module Liquid
|
||||
module Utils
|
||||
DECIMAL_REGEX = /\A-?\d+\.\d+\z/
|
||||
UNIX_TIMESTAMP_REGEX = /\A\d+\z/
|
||||
|
||||
def self.slice_collection(collection, from, to)
|
||||
if (from != 0 || !to.nil?) && collection.respond_to?(:load_slice)
|
||||
collection.load_slice(from, to)
|
||||
@@ -52,7 +55,7 @@ module Liquid
|
||||
when Numeric
|
||||
obj
|
||||
when String
|
||||
/\A-?\d+\.\d+\z/.match?(obj.strip) ? BigDecimal(obj) : obj.to_i
|
||||
DECIMAL_REGEX.match?(obj.strip) ? BigDecimal(obj) : obj.to_i
|
||||
else
|
||||
if obj.respond_to?(:to_number)
|
||||
obj.to_number
|
||||
@@ -73,7 +76,7 @@ module Liquid
|
||||
case obj
|
||||
when 'now', 'today'
|
||||
Time.now
|
||||
when /\A\d+\z/, Integer
|
||||
when UNIX_TIMESTAMP_REGEX, Integer
|
||||
Time.at(obj.to_i)
|
||||
when String
|
||||
Time.parse(obj)
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Liquid
|
||||
VERSION = "5.8.1"
|
||||
VERSION = "5.8.7"
|
||||
end
|
||||
|
||||
@@ -560,12 +560,23 @@ class StandardFiltersTest < Minitest::Test
|
||||
end
|
||||
end
|
||||
|
||||
def test_map_returns_empty_with_no_property
|
||||
def test_map_with_value_property
|
||||
array = [
|
||||
{ "handle" => "alpha", "value" => "A" },
|
||||
{ "handle" => "beta", "value" => "B" },
|
||||
{ "handle" => "gamma", "value" => "C" }
|
||||
]
|
||||
|
||||
assert_template_result("A B C", "{{ array | map: 'value' | join: ' ' }}", { "array" => array })
|
||||
end
|
||||
|
||||
def test_map_returns_input_with_no_property
|
||||
foo = [
|
||||
[1],
|
||||
[2],
|
||||
[3],
|
||||
]
|
||||
|
||||
assert_raises(Liquid::ArgumentError) do
|
||||
@filters.map(foo, nil)
|
||||
end
|
||||
@@ -1033,6 +1044,23 @@ class StandardFiltersTest < Minitest::Test
|
||||
assert_template_result(expected_output, template, { "array" => array })
|
||||
end
|
||||
|
||||
def test_where_with_empty_string_is_a_no_op
|
||||
environment = { "array" => ["alpha", "beta", "gamma"] }
|
||||
expected_output = "alpha beta gamma"
|
||||
template = "{{ array | where: '' | join: ' ' }}"
|
||||
|
||||
assert_template_result(expected_output, template, environment)
|
||||
end
|
||||
|
||||
def test_where_with_nil_is_a_no_op
|
||||
environment = { "array" => ["alpha", "beta", "gamma"] }
|
||||
template = "{{ array | where: nil | join: ' ' }}"
|
||||
|
||||
assert_raises(Liquid::ArgumentError) do
|
||||
assert_template_result("alpha beta gamma", template, environment)
|
||||
end
|
||||
end
|
||||
|
||||
def test_where_with_value
|
||||
array = [
|
||||
{ "handle" => "alpha", "ok" => true },
|
||||
@@ -1268,6 +1296,33 @@ class StandardFiltersTest < Minitest::Test
|
||||
assert_template_result("0", "{{ input | sum: 'subtotal' }}", { "input" => input })
|
||||
end
|
||||
|
||||
def test_sum_with_non_string_property
|
||||
input = [{ true => 1 }, { 1.0 => 0.2, 1 => -0.3 }, { 1..5 => 0.4 }]
|
||||
|
||||
assert_equal(1, @filters.sum(input, true))
|
||||
assert_equal(0.2, @filters.sum(input, 1.0))
|
||||
assert_equal(-0.3, @filters.sum(input, 1))
|
||||
assert_equal(0.4, @filters.sum(input, (1..5)))
|
||||
assert_equal(0, @filters.sum(input, nil))
|
||||
assert_equal(0, @filters.sum(input, ""))
|
||||
end
|
||||
|
||||
def test_uniq_with_to_liquid_value
|
||||
input = [StringDrop.new("foo"), StringDrop.new("bar"), "foo"]
|
||||
expected = [StringDrop.new("foo"), StringDrop.new("bar")]
|
||||
result = @filters.uniq(input)
|
||||
|
||||
assert_equal(expected, result)
|
||||
end
|
||||
|
||||
def test_uniq_with_to_liquid_value_pick_correct_classes
|
||||
input = ["foo", StringDrop.new("foo"), StringDrop.new("bar")]
|
||||
expected = [String, StringDrop]
|
||||
result = @filters.uniq(input).map(&:class)
|
||||
|
||||
assert_equal(expected, result)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def with_timezone(tz)
|
||||
|
||||
@@ -146,6 +146,35 @@ class BooleanDrop < Liquid::Drop
|
||||
end
|
||||
end
|
||||
|
||||
class StringDrop < Liquid::Drop
|
||||
include Comparable
|
||||
|
||||
def initialize(value)
|
||||
super()
|
||||
@value = value
|
||||
end
|
||||
|
||||
def to_liquid_value
|
||||
@value
|
||||
end
|
||||
|
||||
def to_s
|
||||
@value
|
||||
end
|
||||
|
||||
def to_str
|
||||
@value
|
||||
end
|
||||
|
||||
def inspect
|
||||
"#<StringDrop @value=#{@value.inspect}>"
|
||||
end
|
||||
|
||||
def <=>(other)
|
||||
to_liquid_value <=> Liquid::Utils.to_liquid_value(other)
|
||||
end
|
||||
end
|
||||
|
||||
class ErrorDrop < Liquid::Drop
|
||||
def standard_error
|
||||
raise Liquid::StandardError, 'standard error'
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'test_helper'
|
||||
|
||||
class EnvironmentTest < Minitest::Test
|
||||
include Liquid
|
||||
|
||||
class UnsubscribeFooter < Liquid::Tag
|
||||
def render(_context)
|
||||
'Unsubscribe Footer'
|
||||
end
|
||||
end
|
||||
|
||||
def test_custom_tag
|
||||
email_environment = Liquid::Environment.build do |environment|
|
||||
environment.register_tag("unsubscribe_footer", UnsubscribeFooter)
|
||||
end
|
||||
|
||||
assert(email_environment.tags["unsubscribe_footer"])
|
||||
assert(email_environment.tag_for_name("unsubscribe_footer"))
|
||||
template = Liquid::Template.parse("{% unsubscribe_footer %}", environment: email_environment)
|
||||
|
||||
assert_equal('Unsubscribe Footer', template.render)
|
||||
end
|
||||
end
|
||||
@@ -20,6 +20,21 @@ class DocTagUnitTest < Minitest::Test
|
||||
assert_template_result('', template)
|
||||
end
|
||||
|
||||
def test_doc_tag_body_content
|
||||
doc_content = " Documentation content\n @param {string} foo - test\n"
|
||||
template_source = "{% doc %}#{doc_content}{% enddoc %}"
|
||||
|
||||
doc_tag = nil
|
||||
ParseTreeVisitor
|
||||
.for(Template.parse(template_source).root)
|
||||
.add_callback_for(Liquid::Doc) do |tag|
|
||||
doc_tag = tag
|
||||
end
|
||||
.visit
|
||||
|
||||
assert_equal(doc_content, doc_tag.nodelist.first.to_s)
|
||||
end
|
||||
|
||||
def test_doc_tag_does_not_support_extra_arguments
|
||||
error = assert_raises(Liquid::SyntaxError) do
|
||||
template = <<~LIQUID.chomp
|
||||
@@ -116,6 +131,20 @@ class DocTagUnitTest < Minitest::Test
|
||||
assert_template_result('', template)
|
||||
end
|
||||
|
||||
def test_doc_tag_captures_token_before_enddoc
|
||||
template_source = "{% doc %}{{ incomplete{% enddoc %}"
|
||||
|
||||
doc_tag = nil
|
||||
ParseTreeVisitor
|
||||
.for(Template.parse(template_source).root)
|
||||
.add_callback_for(Liquid::Doc) do |tag|
|
||||
doc_tag = tag
|
||||
end
|
||||
.visit
|
||||
|
||||
assert_equal("{{ incomplete", doc_tag.nodelist.first.to_s)
|
||||
end
|
||||
|
||||
def test_doc_tag_preserves_error_line_numbers
|
||||
template = Liquid::Template.parse(<<~LIQUID.chomp, line_numbers: true)
|
||||
{% doc %}
|
||||
@@ -145,11 +174,11 @@ class DocTagUnitTest < Minitest::Test
|
||||
|
||||
def test_doc_tag_delimiter_handling
|
||||
assert_template_result('', <<~LIQUID.chomp)
|
||||
{% if true %}
|
||||
{% doc %}
|
||||
{% docEXTRA %}wut{% enddocEXTRA %}xyz
|
||||
{% enddoc %}
|
||||
{% endif %}
|
||||
{%- if true -%}
|
||||
{%- doc -%}
|
||||
{%- docEXTRA -%}wut{% enddocEXTRA -%}xyz
|
||||
{%- enddoc -%}
|
||||
{%- endif -%}
|
||||
LIQUID
|
||||
|
||||
assert_template_result('', "{% doc %}123{% enddoc xyz %}")
|
||||
@@ -167,6 +196,80 @@ class DocTagUnitTest < Minitest::Test
|
||||
)
|
||||
end
|
||||
|
||||
def test_doc_tag_blank_with_empty_content
|
||||
template_source = "{% doc %}{% enddoc %}"
|
||||
|
||||
doc_tag = nil
|
||||
ParseTreeVisitor
|
||||
.for(Template.parse(template_source).root)
|
||||
.add_callback_for(Liquid::Doc) do |tag|
|
||||
doc_tag = tag
|
||||
end
|
||||
.visit
|
||||
|
||||
assert_equal(true, doc_tag.blank?)
|
||||
end
|
||||
|
||||
def test_doc_tag_blank_with_content
|
||||
template_source = "{% doc %}Some documentation{% enddoc %}"
|
||||
|
||||
doc_tag = nil
|
||||
ParseTreeVisitor
|
||||
.for(Template.parse(template_source).root)
|
||||
.add_callback_for(Liquid::Doc) do |tag|
|
||||
doc_tag = tag
|
||||
end
|
||||
.visit
|
||||
|
||||
assert_equal(false, doc_tag.blank?)
|
||||
end
|
||||
|
||||
def test_doc_tag_blank_with_whitespace_only
|
||||
template_source = "{% doc %} {% enddoc %}"
|
||||
|
||||
doc_tag = nil
|
||||
ParseTreeVisitor
|
||||
.for(Template.parse(template_source).root)
|
||||
.add_callback_for(Liquid::Doc) do |tag|
|
||||
doc_tag = tag
|
||||
end
|
||||
.visit
|
||||
|
||||
assert_equal(false, doc_tag.blank?)
|
||||
end
|
||||
|
||||
def test_doc_tag_nodelist_returns_array_with_body
|
||||
doc_content = "Documentation content\n@param {string} foo"
|
||||
template_source = "{% doc %}#{doc_content}{% enddoc %}"
|
||||
|
||||
doc_tag = nil
|
||||
ParseTreeVisitor
|
||||
.for(Template.parse(template_source).root)
|
||||
.add_callback_for(Liquid::Doc) do |tag|
|
||||
doc_tag = tag
|
||||
end
|
||||
.visit
|
||||
|
||||
assert_equal([doc_content], doc_tag.nodelist)
|
||||
assert_equal(1, doc_tag.nodelist.length)
|
||||
assert_equal(doc_content, doc_tag.nodelist.first)
|
||||
end
|
||||
|
||||
def test_doc_tag_nodelist_with_empty_content
|
||||
template_source = "{% doc %}{% enddoc %}"
|
||||
|
||||
doc_tag = nil
|
||||
ParseTreeVisitor
|
||||
.for(Template.parse(template_source).root)
|
||||
.add_callback_for(Liquid::Doc) do |tag|
|
||||
doc_tag = tag
|
||||
end
|
||||
.visit
|
||||
|
||||
assert_equal([""], doc_tag.nodelist)
|
||||
assert_equal(1, doc_tag.nodelist.length)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def traversal(template)
|
||||
|
||||
Reference in New Issue
Block a user