mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 15:30:39 -07:00
filtered variables for assign, case, and cycle
This commit is contained in:
@@ -9,7 +9,7 @@ module Liquid
|
||||
# {{ monkey }}
|
||||
#
|
||||
class Assign < Tag
|
||||
Syntax = /(#{VariableSignature}+)\s*=\s*(#{QuotedFragment}+)/
|
||||
Syntax = /(#{VariableSignature}+)\s*=\s*(#{Expression}+)/
|
||||
|
||||
def initialize(tag_name, markup, tokens)
|
||||
if markup =~ Syntax
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module Liquid
|
||||
class Case < Block
|
||||
Syntax = /(#{QuotedFragment})/
|
||||
WhenSyntax = /(#{QuotedFragment})(?:(?:\s+or\s+|\s*\,\s*)(#{QuotedFragment}.*))?/
|
||||
Syntax = /(#{Expression})/
|
||||
WhenSyntax = /(#{Expression})(?:(?:\s+or\s+|\s*\,\s*)(#{Expression}.*))?/
|
||||
|
||||
def initialize(tag_name, markup, tokens)
|
||||
@blocks = []
|
||||
|
||||
@@ -13,8 +13,8 @@ module Liquid
|
||||
# <div class="green"> Item five</div>
|
||||
#
|
||||
class Cycle < Tag
|
||||
SimpleSyntax = /#{QuotedFragment}/
|
||||
NamedSyntax = /(#{QuotedFragment})\s*\:\s*(.*)/
|
||||
SimpleSyntax = /#{Expression}/
|
||||
NamedSyntax = /(#{Expression})\s*\:\s*(.*)/
|
||||
|
||||
def initialize(tag_name, markup, tokens)
|
||||
case markup
|
||||
@@ -49,7 +49,7 @@ module Liquid
|
||||
|
||||
def variables_from_string(markup)
|
||||
markup.split(',').collect do |var|
|
||||
var =~ /\s*(#{QuotedFragment})\s*/
|
||||
var =~ /\s*(#{Expression})\s*/
|
||||
$1 ? $1 : nil
|
||||
end.compact
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user