mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-29 07:05:12 -07:00
add variable in c
This commit is contained in:
@@ -12,4 +12,5 @@ void Init_liquid(void)
|
|||||||
|
|
||||||
init_liquid_tokenizer();
|
init_liquid_tokenizer();
|
||||||
init_liquid_block();
|
init_liquid_block();
|
||||||
|
init_liquid_variable();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "tokenizer.h"
|
#include "tokenizer.h"
|
||||||
#include "block.h"
|
#include "block.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "variable.h"
|
||||||
|
|
||||||
extern VALUE mLiquid;
|
extern VALUE mLiquid;
|
||||||
extern VALUE cLiquidTemplate, cLiquidTag, cLiquidVariable;
|
extern VALUE cLiquidTemplate, cLiquidTag, cLiquidVariable;
|
||||||
|
|||||||
+17
-17
@@ -11,7 +11,7 @@ module Liquid
|
|||||||
# {{ user | link }}
|
# {{ user | link }}
|
||||||
#
|
#
|
||||||
class Variable
|
class Variable
|
||||||
FilterParser = /(?:#{FilterSeparator}|(?:\s*(?:#{QuotedFragment}|#{ArgumentSeparator})\s*)+)/o
|
# FilterParser = /(?:#{FilterSeparator}|(?:\s*(?:#{QuotedFragment}|#{ArgumentSeparator})\s*)+)/o
|
||||||
EasyParse = /\A *(\w+(?:\.\w+)*) *\z/
|
EasyParse = /\A *(\w+(?:\.\w+)*) *\z/
|
||||||
attr_accessor :filters, :name, :warnings
|
attr_accessor :filters, :name, :warnings
|
||||||
|
|
||||||
@@ -35,22 +35,22 @@ module Liquid
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def lax_parse(markup)
|
# def lax_parse(markup)
|
||||||
@filters = []
|
# @filters = []
|
||||||
if match = markup.match(/\s*(#{QuotedFragment})(.*)/o)
|
# if match = markup.match(/\s*(#{QuotedFragment})(.*)/o)
|
||||||
@name = match[1]
|
# @name = match[1]
|
||||||
if match[2].match(/#{FilterSeparator}\s*(.*)/o)
|
# if match[2].match(/#{FilterSeparator}\s*(.*)/o)
|
||||||
filters = Regexp.last_match(1).scan(FilterParser)
|
# filters = Regexp.last_match(1).scan(FilterParser)
|
||||||
filters.each do |f|
|
# filters.each do |f|
|
||||||
if matches = f.match(/\s*(\w+)/)
|
# if matches = f.match(/\s*(\w+)/)
|
||||||
filtername = matches[1]
|
# filtername = matches[1]
|
||||||
filterargs = f.scan(/(?:#{FilterArgumentSeparator}|#{ArgumentSeparator})\s*((?:\w+\s*\:\s*)?#{QuotedFragment})/o).flatten
|
# filterargs = f.scan(/(?:#{FilterArgumentSeparator}|#{ArgumentSeparator})\s*((?:\w+\s*\:\s*)?#{QuotedFragment})/o).flatten
|
||||||
@filters << [filtername, filterargs]
|
# @filters << [filtername, filterargs]
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
|
||||||
def strict_parse(markup)
|
def strict_parse(markup)
|
||||||
# Very simple valid cases
|
# Very simple valid cases
|
||||||
|
|||||||
Reference in New Issue
Block a user