mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
Reverted james filter in tags branch
This reverts commit 282786d7e2.
Conflicts:
lib/liquid.rb
lib/liquid/variable.rb
test/if_else_test.rb
This commit is contained in:
+2
-8
@@ -22,7 +22,7 @@
|
||||
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
||||
|
||||
module Liquid
|
||||
FilterSeparator = /\|/
|
||||
FilterSperator = /\|/
|
||||
ArgumentSeparator = ','
|
||||
FilterArgumentSeparator = ':'
|
||||
VariableAttributeSeparator = '.'
|
||||
@@ -33,13 +33,7 @@ module Liquid
|
||||
VariableStart = /\{\{/
|
||||
VariableEnd = /\}\}/
|
||||
VariableIncompleteEnd = /\}\}?/
|
||||
QuotedString = /"[^"]+"|'[^']+'/
|
||||
QuotedFragment = /#{QuotedString}|(?:[^\s,\|'"]|#{QuotedString})+/
|
||||
StrictQuotedFragment = /"[^"]+"|'[^']+'|[^\s,\|,\:,\,]+/
|
||||
FirstFilterArgument = /#{FilterArgumentSeparator}(?:#{StrictQuotedFragment})/
|
||||
OtherFilterArgument = /#{ArgumentSeparator}(?:#{StrictQuotedFragment})/
|
||||
SpacelessFilter = /#{FilterSeparator}(?:#{StrictQuotedFragment})(?:#{FirstFilterArgument}(?:#{OtherFilterArgument})*)?/
|
||||
Expression = /(?:#{QuotedFragment}(?:#{SpacelessFilter})*)/
|
||||
QuotedFragment = /"[^"]+"|'[^']+'|[^\s,|]+/
|
||||
TagAttributes = /(\w+)\s*\:\s*(#{QuotedFragment})/
|
||||
AnyStartingTag = /\{\{|\{\%/
|
||||
PartialTemplateParser = /#{TagStart}.*?#{TagEnd}|#{VariableStart}.*?#{VariableIncompleteEnd}/
|
||||
|
||||
@@ -133,9 +133,6 @@ module Liquid
|
||||
:blank?
|
||||
when 'empty'
|
||||
:empty?
|
||||
# filtered variables
|
||||
when SpacelessFilter
|
||||
filtered_variable(key)
|
||||
# Single quoted strings
|
||||
when /^'(.*)'$/
|
||||
$1.to_s
|
||||
@@ -224,9 +221,5 @@ module Liquid
|
||||
|
||||
object
|
||||
end
|
||||
|
||||
def filtered_variable(markup)
|
||||
Variable.new(markup).render(self)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ module Liquid
|
||||
# {{ monkey }}
|
||||
#
|
||||
class Assign < Tag
|
||||
Syntax = /(#{VariableSignature}+)\s*=\s*(#{Expression}+)/
|
||||
Syntax = /(#{VariableSignature}+)\s*=\s*(#{QuotedFragment}+)/
|
||||
|
||||
def initialize(tag_name, markup, tokens)
|
||||
if markup =~ Syntax
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module Liquid
|
||||
class Case < Block
|
||||
Syntax = /(#{Expression})/
|
||||
WhenSyntax = /(#{Expression})(?:(?:\s+or\s+|\s*\,\s*)(#{Expression}.*))?/
|
||||
Syntax = /(#{QuotedFragment})/
|
||||
WhenSyntax = /(#{QuotedFragment})(?:(?:\s+or\s+|\s*\,\s*)(#{QuotedFragment}.*))?/
|
||||
|
||||
def initialize(tag_name, markup, tokens)
|
||||
@blocks = []
|
||||
|
||||
@@ -13,8 +13,8 @@ module Liquid
|
||||
# <div class="green"> Item five</div>
|
||||
#
|
||||
class Cycle < Tag
|
||||
SimpleSyntax = /^#{Expression}/
|
||||
NamedSyntax = /^(#{Expression})\s*\:\s*(.*)/
|
||||
SimpleSyntax = /^#{QuotedFragment}/
|
||||
NamedSyntax = /^(#{QuotedFragment})\s*\:\s*(.*)/
|
||||
|
||||
def initialize(tag_name, markup, tokens)
|
||||
case markup
|
||||
@@ -48,7 +48,7 @@ module Liquid
|
||||
|
||||
def variables_from_string(markup)
|
||||
markup.split(',').collect do |var|
|
||||
var =~ /\s*(#{Expression})\s*/
|
||||
var =~ /\s*(#{QuotedFragment})\s*/
|
||||
$1 ? $1 : nil
|
||||
end.compact
|
||||
end
|
||||
|
||||
@@ -42,7 +42,7 @@ module Liquid
|
||||
# forloop.last:: Returns true if the item is the last item.
|
||||
#
|
||||
class For < Block
|
||||
Syntax = /(\w+)\s+in\s+(#{Expression}+)\s*(reversed)?/
|
||||
Syntax = /(\w+)\s+in\s+(#{QuotedFragment}+)\s*(reversed)?/
|
||||
|
||||
def initialize(tag_name, markup, tokens)
|
||||
if markup =~ Syntax
|
||||
|
||||
@@ -13,7 +13,7 @@ module Liquid
|
||||
#
|
||||
class If < Block
|
||||
SyntaxHelp = "Syntax Error in tag 'if' - Valid syntax: if [expression]"
|
||||
Syntax = /(#{Expression})\s*([=!<>a-z_]+)?\s*(#{Expression})?/
|
||||
Syntax = /(#{QuotedFragment})\s*([=!<>a-z_]+)?\s*(#{QuotedFragment})?/
|
||||
|
||||
def initialize(tag_name, markup, tokens)
|
||||
|
||||
|
||||
@@ -19,8 +19,9 @@ module Liquid
|
||||
@filters = []
|
||||
if match = markup.match(/\s*(#{QuotedFragment})/)
|
||||
@name = match[1]
|
||||
if markup.match(/#{FilterSeparator}\s*(.*)/)
|
||||
filters = Regexp.last_match(1).split(/#{FilterSeparator}/)
|
||||
if markup.match(/#{FilterSperator}\s*(.*)/)
|
||||
filters = Regexp.last_match(1).split(/#{FilterSperator}/)
|
||||
|
||||
filters.each do |f|
|
||||
if matches = f.match(/\s*(\w+)/)
|
||||
filtername = matches[1]
|
||||
|
||||
Reference in New Issue
Block a user