Skip to content

Instantly share code, notes, and snippets.

@arika
Created March 29, 2012 09:31
Show Gist options
  • Save arika/2235388 to your computer and use it in GitHub Desktop.
Save arika/2235388 to your computer and use it in GitHub Desktop.
# modified lib/liquid/variable.rb of liquid 2.2.2
module Liquid
class Variable
def initialize(markup)
@markup = markup
@name = nil
@filters = []
if match = markup.match(/\s*(#{QuotedFragment})(.*)/o)
@name = match[1]
if match[2].match(/#{FilterSeparator}\s*(.*)/o)
filters = Regexp.last_match(1).scan(FilterParser)
filters.each do |f|
if matches = f.match(/\s*(\w+)/)
filtername = matches[1]
filterargs = f.scan(/(?:#{FilterArgumentSeparator}|#{ArgumentSeparator})\s*(#{QuotedFragment})/o).flatten
@filters << [filtername.to_sym, filterargs]
end
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment