mirror of
https://github.com/kemko/liquid.git
synced 2026-01-03 00:35:40 +03:00
Compare commits
6 Commits
remove-ext
...
inline-com
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0fc45ca3af | ||
|
|
ab455480fa | ||
|
|
5e8e5e89b1 | ||
|
|
6ddfaec3f9 | ||
|
|
fff6c565c1 | ||
|
|
31f7be8a6d |
1022
.rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml
Normal file
1022
.rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml
Normal file
File diff suppressed because it is too large
Load Diff
10
.rubocop.yml
10
.rubocop.yml
@@ -1,7 +1,5 @@
|
|||||||
inherit_gem:
|
|
||||||
rubocop-shopify: rubocop.yml
|
|
||||||
|
|
||||||
inherit_from:
|
inherit_from:
|
||||||
|
- 'https://shopify.github.io/ruby-style-guide/rubocop.yml'
|
||||||
- .rubocop_todo.yml
|
- .rubocop_todo.yml
|
||||||
|
|
||||||
require: rubocop-performance
|
require: rubocop-performance
|
||||||
@@ -10,7 +8,7 @@ Performance:
|
|||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
AllCops:
|
AllCops:
|
||||||
TargetRubyVersion: 2.5
|
TargetRubyVersion: 2.4
|
||||||
NewCops: disable
|
NewCops: disable
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'vendor/bundle/**/*'
|
- 'vendor/bundle/**/*'
|
||||||
@@ -18,7 +16,3 @@ AllCops:
|
|||||||
Naming/MethodName:
|
Naming/MethodName:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'example/server/liquid_servlet.rb'
|
- 'example/server/liquid_servlet.rb'
|
||||||
|
|
||||||
# Backport https://github.com/Shopify/ruby-style-guide/pull/258
|
|
||||||
Layout/BeginEndAlignment:
|
|
||||||
Enabled: true
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
* Bugfixes
|
* Bugfixes
|
||||||
* Performance improvements
|
* Performance improvements
|
||||||
* Features that are likely to be useful to the majority of Liquid users
|
* Features that are likely to be useful to the majority of Liquid users
|
||||||
* Documentation updates that are concise and likely to be useful to the majority of Liquid users
|
|
||||||
|
|
||||||
## Things we won't merge
|
## Things we won't merge
|
||||||
|
|
||||||
@@ -15,14 +14,12 @@
|
|||||||
* Features that can easily be implemented on top of Liquid (for example as a custom filter or custom filesystem)
|
* Features that can easily be implemented on top of Liquid (for example as a custom filter or custom filesystem)
|
||||||
* Code that does not include tests
|
* Code that does not include tests
|
||||||
* Code that breaks existing tests
|
* Code that breaks existing tests
|
||||||
* Documentation changes that are verbose, incorrect or not important to most people (we want to keep it simple and easy to understand)
|
|
||||||
|
|
||||||
## Workflow
|
## Workflow
|
||||||
|
|
||||||
* [Sign the CLA](https://cla.shopify.com/) if you haven't already
|
|
||||||
* Fork the Liquid repository
|
* Fork the Liquid repository
|
||||||
* Create a new branch in your fork
|
* Create a new branch in your fork
|
||||||
* For updating [Liquid documentation](https://shopify.github.io/liquid/), create it from `gh-pages` branch. (You can skip tests.)
|
|
||||||
* If it makes sense, add tests for your code and/or run a performance benchmark
|
* If it makes sense, add tests for your code and/or run a performance benchmark
|
||||||
* Make sure all tests pass (`bundle exec rake`)
|
* Make sure all tests pass (`bundle exec rake`)
|
||||||
* Create a pull request
|
* Create a pull request
|
||||||
|
|
||||||
|
|||||||
3
Gemfile
3
Gemfile
@@ -19,10 +19,9 @@ end
|
|||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
gem 'rubocop', '~> 1.4', require: false
|
gem 'rubocop', '~> 1.4', require: false
|
||||||
gem 'rubocop-shopify', '~> 1.0.7', require: false
|
|
||||||
gem 'rubocop-performance', require: false
|
gem 'rubocop-performance', require: false
|
||||||
|
|
||||||
platform :mri, :truffleruby do
|
platform :mri, :truffleruby do
|
||||||
gem 'liquid-c', github: 'Shopify/liquid-c', ref: 'master'
|
gem 'liquid-c', github: 'Shopify/liquid-c', ref: 'inline-comment'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
16
History.md
16
History.md
@@ -1,19 +1,9 @@
|
|||||||
# Liquid Change Log
|
# Liquid Change Log
|
||||||
|
|
||||||
## 5.0.2 (unreleased)
|
## Unreleased
|
||||||
|
|
||||||
### Fixes
|
### Features
|
||||||
* Fix support for using a String subclass for the liquid source (#1421) [Dylan Thacker-Smith]
|
* Allow `#` to be used as an inline comment tag (#1401) [Dylan Thacker-Smith]
|
||||||
|
|
||||||
## 5.0.1 / 2021-03-24
|
|
||||||
|
|
||||||
### Fixes
|
|
||||||
* Add ParseTreeVisitor to Echo tag (#1414) [CP Clermont]
|
|
||||||
* Test with ruby 3.0 as the latest ruby version (#1398) [Dylan Thacker-Smith]
|
|
||||||
* Handle carriage return in newlines_to_br (#1391) [Unending]
|
|
||||||
|
|
||||||
### Performance Improvements
|
|
||||||
* Use split limit in truncatewords (#1361) [Dylan Thacker-Smith]
|
|
||||||
|
|
||||||
## 5.0.0 / 2021-01-06
|
## 5.0.0 / 2021-01-06
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ require 'English'
|
|||||||
|
|
||||||
module Liquid
|
module Liquid
|
||||||
class BlockBody
|
class BlockBody
|
||||||
LiquidTagToken = /\A\s*(\w+)\s*(.*?)\z/o
|
LiquidTagToken = /\A\s*(\w+|#)\s*(.*?)\z/o
|
||||||
FullToken = /\A#{TagStart}#{WhitespaceControl}?(\s*)(\w+)(\s*)(.*?)#{WhitespaceControl}?#{TagEnd}\z/om
|
FullToken = /\A#{TagStart}#{WhitespaceControl}?(\s*)(\w+|#)(\s*)(.*?)#{WhitespaceControl}?#{TagEnd}\z/om
|
||||||
ContentOfVariable = /\A#{VariableStart}#{WhitespaceControl}?(.*?)#{WhitespaceControl}?#{VariableEnd}\z/om
|
ContentOfVariable = /\A#{VariableStart}#{WhitespaceControl}?(.*?)#{WhitespaceControl}?#{VariableEnd}\z/om
|
||||||
WhitespaceOrNothing = /\A\s*\z/
|
WhitespaceOrNothing = /\A\s*\z/
|
||||||
TAGSTART = "{%"
|
TAGSTART = "{%"
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
tag_never_closed: "'%{block_name}' tag was never closed"
|
tag_never_closed: "'%{block_name}' tag was never closed"
|
||||||
table_row: "Syntax Error in 'table_row loop' - Valid syntax: table_row [item] in [collection] cols=3"
|
table_row: "Syntax Error in 'table_row loop' - Valid syntax: table_row [item] in [collection] cols=3"
|
||||||
render: "Syntax error in tag 'render' - Template name must be a quoted string"
|
render: "Syntax error in tag 'render' - Template name must be a quoted string"
|
||||||
|
inline_comment_invalid: "Syntax error in tag '#' - Each line of comments must be prefixed by the '#' character"
|
||||||
argument:
|
argument:
|
||||||
include: "Argument error in tag 'include' - Illegal template name"
|
include: "Argument error in tag 'include' - Illegal template name"
|
||||||
disabled:
|
disabled:
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ require 'bigdecimal'
|
|||||||
|
|
||||||
module Liquid
|
module Liquid
|
||||||
module StandardFilters
|
module StandardFilters
|
||||||
MAX_INT = (1 << 31) - 1
|
|
||||||
HTML_ESCAPE = {
|
HTML_ESCAPE = {
|
||||||
'&' => '&',
|
'&' => '&',
|
||||||
'>' => '>',
|
'>' => '>',
|
||||||
@@ -94,13 +93,7 @@ module Liquid
|
|||||||
words = Utils.to_integer(words)
|
words = Utils.to_integer(words)
|
||||||
words = 1 if words <= 0
|
words = 1 if words <= 0
|
||||||
|
|
||||||
wordlist = begin
|
wordlist = input.split(" ", words + 1)
|
||||||
input.split(" ", words + 1)
|
|
||||||
rescue RangeError
|
|
||||||
raise if words + 1 < MAX_INT
|
|
||||||
# e.g. integer #{words} too big to convert to `int'
|
|
||||||
raise Liquid::ArgumentError, "integer #{words} too big for truncatewords"
|
|
||||||
end
|
|
||||||
return input if wordlist.length <= words
|
return input if wordlist.length <= words
|
||||||
|
|
||||||
wordlist.pop
|
wordlist.pop
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ module Liquid
|
|||||||
# {% echo user | link %}
|
# {% echo user | link %}
|
||||||
#
|
#
|
||||||
class Echo < Tag
|
class Echo < Tag
|
||||||
attr_reader :variable
|
|
||||||
|
|
||||||
def initialize(tag_name, markup, parse_context)
|
def initialize(tag_name, markup, parse_context)
|
||||||
super
|
super
|
||||||
@variable = Variable.new(markup, parse_context)
|
@variable = Variable.new(markup, parse_context)
|
||||||
@@ -22,12 +20,6 @@ module Liquid
|
|||||||
def render(context)
|
def render(context)
|
||||||
@variable.render_to_output_buffer(context, +'')
|
@variable.render_to_output_buffer(context, +'')
|
||||||
end
|
end
|
||||||
|
|
||||||
class ParseTreeVisitor < Liquid::ParseTreeVisitor
|
|
||||||
def children
|
|
||||||
[@node.variable]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Template.register_tag('echo', Echo)
|
Template.register_tag('echo', Echo)
|
||||||
|
|||||||
25
lib/liquid/tags/inline_comment.rb
Normal file
25
lib/liquid/tags/inline_comment.rb
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Liquid
|
||||||
|
class InlineComment < Tag
|
||||||
|
def initialize(tag_name, markup, options)
|
||||||
|
super
|
||||||
|
# Semantically, a comment should only ignore everything after it on the line.
|
||||||
|
# Currently, this implementation doesn't support mixing a comment with another tag
|
||||||
|
# but we need to reserve future support for this.
|
||||||
|
if markup.match?(/\n\s*[^#]/)
|
||||||
|
raise SyntaxError, options[:locale].t("errors.syntax.inline_comment_invalid")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def render_to_output_buffer(_context, output)
|
||||||
|
output
|
||||||
|
end
|
||||||
|
|
||||||
|
def blank?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Template.register_tag('#', InlineComment)
|
||||||
|
end
|
||||||
@@ -5,7 +5,7 @@ module Liquid
|
|||||||
attr_reader :line_number, :for_liquid_tag
|
attr_reader :line_number, :for_liquid_tag
|
||||||
|
|
||||||
def initialize(source, line_numbers = false, line_number: nil, for_liquid_tag: false)
|
def initialize(source, line_numbers = false, line_number: nil, for_liquid_tag: false)
|
||||||
@source = source.to_s.to_str
|
@source = source
|
||||||
@line_number = line_number || (line_numbers ? 1 : nil)
|
@line_number = line_number || (line_numbers ? 1 : nil)
|
||||||
@for_liquid_tag = for_liquid_tag
|
@for_liquid_tag = for_liquid_tag
|
||||||
@tokens = tokenize
|
@tokens = tokenize
|
||||||
@@ -24,7 +24,7 @@ module Liquid
|
|||||||
private
|
private
|
||||||
|
|
||||||
def tokenize
|
def tokenize
|
||||||
return [] if @source.empty?
|
return [] if @source.to_s.empty?
|
||||||
|
|
||||||
return @source.split("\n") if @for_liquid_tag
|
return @source.split("\n") if @for_liquid_tag
|
||||||
|
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Liquid
|
module Liquid
|
||||||
VERSION = "5.0.2.alpha"
|
VERSION = "5.0.0"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ module ShopFilter
|
|||||||
end
|
end
|
||||||
|
|
||||||
def script_tag(url)
|
def script_tag(url)
|
||||||
%(<script src="#{url}"></script>)
|
%(<script src="#{url}" type="text/javascript"></script>)
|
||||||
end
|
end
|
||||||
|
|
||||||
def stylesheet_tag(url, media = "all")
|
def stylesheet_tag(url, media = "all")
|
||||||
%(<link href="#{url}" rel="stylesheet" #{%(media="#{media}" ) unless media == 'all'}/>)
|
%(<link href="#{url}" rel="stylesheet" type="text/css" media="#{media}" />)
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_to(link, url, title = "")
|
def link_to(link, url, title = "")
|
||||||
|
|||||||
@@ -171,17 +171,13 @@ class StandardFiltersTest < Minitest::Test
|
|||||||
assert_equal('one two three', @filters.truncatewords('one two three'))
|
assert_equal('one two three', @filters.truncatewords('one two three'))
|
||||||
assert_equal(
|
assert_equal(
|
||||||
'Two small (13” x 5.5” x 10” high) baskets fit inside one large basket (13”...',
|
'Two small (13” x 5.5” x 10” high) baskets fit inside one large basket (13”...',
|
||||||
@filters.truncatewords('Two small (13” x 5.5” x 10” high) baskets fit inside one large basket (13” x 16” x 10.5” high) with cover.', 15)
|
@filters.truncatewords('Two small (13” x 5.5” x 10” high) baskets fit inside one large basket (13” x 16” x 10.5” high) with cover.', 15)
|
||||||
)
|
)
|
||||||
assert_equal("测试测试测试测试", @filters.truncatewords('测试测试测试测试', 5))
|
assert_equal("测试测试测试测试", @filters.truncatewords('测试测试测试测试', 5))
|
||||||
assert_equal('one two1', @filters.truncatewords("one two three", 2, 1))
|
assert_equal('one two1', @filters.truncatewords("one two three", 2, 1))
|
||||||
assert_equal('one two three...', @filters.truncatewords("one two\tthree\nfour", 3))
|
assert_equal('one two three...', @filters.truncatewords("one two\tthree\nfour", 3))
|
||||||
assert_equal('one two...', @filters.truncatewords("one two three four", 2))
|
assert_equal('one two...', @filters.truncatewords("one two three four", 2))
|
||||||
assert_equal('one...', @filters.truncatewords("one two three four", 0))
|
assert_equal('one...', @filters.truncatewords("one two three four", 0))
|
||||||
exception = assert_raises(Liquid::ArgumentError) do
|
|
||||||
@filters.truncatewords("one two three four", 1 << 31)
|
|
||||||
end
|
|
||||||
assert_equal("Liquid error: integer #{1 << 31} too big for truncatewords", exception.message)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_strip_html
|
def test_strip_html
|
||||||
|
|||||||
@@ -96,12 +96,12 @@ class IncludeTagTest < Minitest::Test
|
|||||||
|
|
||||||
def test_include_tag_with_alias
|
def test_include_tag_with_alias
|
||||||
assert_template_result("Product: Draft 151cm ",
|
assert_template_result("Product: Draft 151cm ",
|
||||||
"{% include 'product_alias' with products[0] as product %}", "products" => [{ 'title' => 'Draft 151cm' }, { 'title' => 'Element 155cm' }])
|
"{% include 'product_alias' with products[0] as product %}", "products" => [{ 'title' => 'Draft 151cm' }, { 'title' => 'Element 155cm' }])
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_include_tag_for_alias
|
def test_include_tag_for_alias
|
||||||
assert_template_result("Product: Draft 151cm Product: Element 155cm ",
|
assert_template_result("Product: Draft 151cm Product: Element 155cm ",
|
||||||
"{% include 'product_alias' for products as product %}", "products" => [{ 'title' => 'Draft 151cm' }, { 'title' => 'Element 155cm' }])
|
"{% include 'product_alias' for products as product %}", "products" => [{ 'title' => 'Draft 151cm' }, { 'title' => 'Element 155cm' }])
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_include_tag_with_default_name
|
def test_include_tag_with_default_name
|
||||||
|
|||||||
59
test/integration/tags/inline_comment_test.rb
Normal file
59
test/integration/tags/inline_comment_test.rb
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class InlineCommentTest < Minitest::Test
|
||||||
|
include Liquid
|
||||||
|
|
||||||
|
def test_tag_in_different_styles
|
||||||
|
assert_template_result('', '{% # This text gets ignored %}')
|
||||||
|
assert_template_result('', '{%# This text gets ignored #%}')
|
||||||
|
assert_template_result('', '{%# This text gets ignored %}')
|
||||||
|
assert_template_result('', '{%#- This text gets ignored -#%}')
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_test_syntax_error
|
||||||
|
assert_template_result('fail', '{% #This doesnt work %}')
|
||||||
|
|
||||||
|
assert false
|
||||||
|
rescue
|
||||||
|
# ok good
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_tag_ws_stripping
|
||||||
|
assert_template_result('', ' {%#- This text gets ignored -#%} ')
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_comment_inline_tag
|
||||||
|
assert_template_result('ok', '{% echo "ok" # output something from a tag %}')
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_comment_line_before_tag
|
||||||
|
assert_template_result('ok', '{% # this sort of comment also
|
||||||
|
echo "ok" %}')
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_comment_inline_variable
|
||||||
|
assert_template_result('ok', '{{ "ok" # output something from a variable }}')
|
||||||
|
assert_template_result('ok', '{{ "OK" | downcase # output something from a variable }}')
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_inside_liquid_tag
|
||||||
|
source = <<~LIQUID
|
||||||
|
{%- liquid
|
||||||
|
echo "before("
|
||||||
|
# This text gets ignored
|
||||||
|
echo ")after"
|
||||||
|
-%}
|
||||||
|
LIQUID
|
||||||
|
assert_template_result('before()after', source)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_multiline
|
||||||
|
assert_template_result('', '{% # this sort of comment also
|
||||||
|
# will just work, because it parses
|
||||||
|
# as a single call to the "#" tag %}')
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -151,7 +151,7 @@ class RenderTagTest < Minitest::Test
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert_template_result("Product: Draft 151cm ",
|
assert_template_result("Product: Draft 151cm ",
|
||||||
"{% render 'product' with products[0] %}", "products" => [{ 'title' => 'Draft 151cm' }, { 'title' => 'Element 155cm' }])
|
"{% render 'product' with products[0] %}", "products" => [{ 'title' => 'Draft 151cm' }, { 'title' => 'Element 155cm' }])
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_render_tag_with_alias
|
def test_render_tag_with_alias
|
||||||
@@ -161,7 +161,7 @@ class RenderTagTest < Minitest::Test
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert_template_result("Product: Draft 151cm ",
|
assert_template_result("Product: Draft 151cm ",
|
||||||
"{% render 'product_alias' with products[0] as product %}", "products" => [{ 'title' => 'Draft 151cm' }, { 'title' => 'Element 155cm' }])
|
"{% render 'product_alias' with products[0] as product %}", "products" => [{ 'title' => 'Draft 151cm' }, { 'title' => 'Element 155cm' }])
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_render_tag_for_alias
|
def test_render_tag_for_alias
|
||||||
@@ -171,7 +171,7 @@ class RenderTagTest < Minitest::Test
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert_template_result("Product: Draft 151cm Product: Element 155cm ",
|
assert_template_result("Product: Draft 151cm Product: Element 155cm ",
|
||||||
"{% render 'product_alias' for products as product %}", "products" => [{ 'title' => 'Draft 151cm' }, { 'title' => 'Element 155cm' }])
|
"{% render 'product_alias' for products as product %}", "products" => [{ 'title' => 'Draft 151cm' }, { 'title' => 'Element 155cm' }])
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_render_tag_for
|
def test_render_tag_for
|
||||||
@@ -181,7 +181,7 @@ class RenderTagTest < Minitest::Test
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert_template_result("Product: Draft 151cm Product: Element 155cm ",
|
assert_template_result("Product: Draft 151cm Product: Element 155cm ",
|
||||||
"{% render 'product' for products %}", "products" => [{ 'title' => 'Draft 151cm' }, { 'title' => 'Element 155cm' }])
|
"{% render 'product' for products %}", "products" => [{ 'title' => 'Draft 151cm' }, { 'title' => 'Element 155cm' }])
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_render_tag_forloop
|
def test_render_tag_forloop
|
||||||
@@ -190,7 +190,7 @@ class RenderTagTest < Minitest::Test
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert_template_result("Product: Draft 151cm first index:1 Product: Element 155cm last index:2 ",
|
assert_template_result("Product: Draft 151cm first index:1 Product: Element 155cm last index:2 ",
|
||||||
"{% render 'product' for products %}", "products" => [{ 'title' => 'Draft 151cm' }, { 'title' => 'Element 155cm' }])
|
"{% render 'product' for products %}", "products" => [{ 'title' => 'Draft 151cm' }, { 'title' => 'Element 155cm' }])
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_render_tag_for_drop
|
def test_render_tag_for_drop
|
||||||
@@ -199,7 +199,7 @@ class RenderTagTest < Minitest::Test
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert_template_result("123",
|
assert_template_result("123",
|
||||||
"{% render 'loop' for loop as value %}", "loop" => TestEnumerable.new)
|
"{% render 'loop' for loop as value %}", "loop" => TestEnumerable.new)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_render_tag_with_drop
|
def test_render_tag_with_drop
|
||||||
@@ -208,6 +208,6 @@ class RenderTagTest < Minitest::Test
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert_template_result("TestEnumerable",
|
assert_template_result("TestEnumerable",
|
||||||
"{% render 'loop' with loop as value %}", "loop" => TestEnumerable.new)
|
"{% render 'loop' with loop as value %}", "loop" => TestEnumerable.new)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -323,18 +323,4 @@ class TemplateTest < Minitest::Test
|
|||||||
result = t.render('x' => 1, 'y' => 5)
|
result = t.render('x' => 1, 'y' => 5)
|
||||||
assert_equal('12345', result)
|
assert_equal('12345', result)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_source_string_subclass
|
|
||||||
string_subclass = Class.new(String) do
|
|
||||||
# E.g. ActiveSupport::SafeBuffer does this, so don't just rely on to_s to return a String
|
|
||||||
def to_s
|
|
||||||
self
|
|
||||||
end
|
|
||||||
end
|
|
||||||
source = string_subclass.new("{% assign x = 2 -%} x= {{- x }}")
|
|
||||||
assert_instance_of(string_subclass, source)
|
|
||||||
output = Template.parse(source).render!
|
|
||||||
assert_equal("x=2", output)
|
|
||||||
assert_instance_of(String, output)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -26,13 +26,6 @@ class ParseTreeVisitorTest < Minitest::Test
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_echo
|
|
||||||
assert_equal(
|
|
||||||
["test"],
|
|
||||||
visit(%({% echo test %}))
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_if_condition
|
def test_if_condition
|
||||||
assert_equal(
|
assert_equal(
|
||||||
["test"],
|
["test"],
|
||||||
|
|||||||
Reference in New Issue
Block a user