Skip to content

Commit dd0b2af

Browse files
committed
.
1 parent 5759412 commit dd0b2af

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
<p>Hello world!</p>
1+
{% let hey = 'guilherme' %}
22

3-
<p>It is {{date}}</p>
4-
5-
6-
<p>Check out the <a href="/products">Products</a> screen </p>
3+
{{ hey | upcase }}

lib/liquid/tags/let.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,20 @@ def children
111111

112112
private
113113

114-
MULTI_VALUE_KEYWORDS = %w[options accept].freeze
114+
MULTI_VALUE_KEYWORDS = ['options', 'accept'].freeze
115115

116116
def build_metadata_json(context, default_val)
117117
parts = []
118118
parts << "\"type\":#{json_encode(@inferred_type)}"
119119
parts << "\"default\":#{json_encode(default_val)}"
120120

121+
if context.template_name
122+
parts << "\"template\":#{json_encode(context.template_name)}"
123+
end
124+
121125
@attributes.each do |key, expr|
122126
next if key == "type"
127+
123128
parts << "#{json_encode(key)}:#{json_encode(context.evaluate(expr))}"
124129
end
125130

@@ -158,7 +163,7 @@ def lax_parse_keywords(remaining)
158163
if remaining =~ /\A,\s*/
159164
after_comma = Regexp.last_match.post_match
160165
# If next token after comma is a keyword: pattern, stop consuming values
161-
if after_comma =~ /\A(\w[\w-]*)\s*:/
166+
if /\A(\w[\w-]*)\s*:/.match?(after_comma)
162167
remaining = after_comma
163168
break
164169
else
@@ -173,12 +178,10 @@ def lax_parse_keywords(remaining)
173178
else
174179
@accept_list = values
175180
end
176-
else
177-
if remaining =~ /\A(#{QuotedFragment})/o
178-
@attributes[key] = parse_expression(Regexp.last_match(1))
179-
remaining = Regexp.last_match.post_match.strip
180-
remaining = remaining.sub(/\A,\s*/, '')
181-
end
181+
elsif remaining =~ /\A(#{QuotedFragment})/o
182+
@attributes[key] = parse_expression(Regexp.last_match(1))
183+
remaining = Regexp.last_match.post_match.strip
184+
remaining = remaining.sub(/\A,\s*/, '')
182185
end
183186
end
184187
end

0 commit comments

Comments
 (0)