liquid 2.6.3 → 5.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/History.md +272 -26
- data/README.md +67 -3
- data/lib/liquid/block.rb +62 -94
- data/lib/liquid/block_body.rb +255 -0
- data/lib/liquid/condition.rb +96 -38
- data/lib/liquid/context.rb +172 -154
- data/lib/liquid/document.rb +57 -9
- data/lib/liquid/drop.rb +33 -14
- data/lib/liquid/errors.rb +56 -10
- data/lib/liquid/expression.rb +45 -0
- data/lib/liquid/extensions.rb +21 -7
- data/lib/liquid/file_system.rb +27 -14
- data/lib/liquid/forloop_drop.rb +92 -0
- data/lib/liquid/i18n.rb +41 -0
- data/lib/liquid/interrupts.rb +3 -2
- data/lib/liquid/lexer.rb +62 -0
- data/lib/liquid/locales/en.yml +29 -0
- data/lib/liquid/parse_context.rb +54 -0
- data/lib/liquid/parse_tree_visitor.rb +42 -0
- data/lib/liquid/parser.rb +102 -0
- data/lib/liquid/parser_switching.rb +45 -0
- data/lib/liquid/partial_cache.rb +24 -0
- data/lib/liquid/profiler/hooks.rb +35 -0
- data/lib/liquid/profiler.rb +139 -0
- data/lib/liquid/range_lookup.rb +47 -0
- data/lib/liquid/registers.rb +51 -0
- data/lib/liquid/resource_limits.rb +62 -0
- data/lib/liquid/standardfilters.rb +789 -118
- data/lib/liquid/strainer_factory.rb +41 -0
- data/lib/liquid/strainer_template.rb +62 -0
- data/lib/liquid/tablerowloop_drop.rb +121 -0
- data/lib/liquid/tag/disableable.rb +22 -0
- data/lib/liquid/tag/disabler.rb +21 -0
- data/lib/liquid/tag.rb +49 -10
- data/lib/liquid/tags/assign.rb +61 -19
- data/lib/liquid/tags/break.rb +14 -4
- data/lib/liquid/tags/capture.rb +29 -21
- data/lib/liquid/tags/case.rb +80 -31
- data/lib/liquid/tags/comment.rb +24 -2
- data/lib/liquid/tags/continue.rb +14 -13
- data/lib/liquid/tags/cycle.rb +50 -32
- data/lib/liquid/tags/decrement.rb +24 -26
- data/lib/liquid/tags/echo.rb +41 -0
- data/lib/liquid/tags/for.rb +164 -100
- data/lib/liquid/tags/if.rb +105 -44
- data/lib/liquid/tags/ifchanged.rb +10 -11
- data/lib/liquid/tags/include.rb +85 -65
- data/lib/liquid/tags/increment.rb +24 -22
- data/lib/liquid/tags/inline_comment.rb +43 -0
- data/lib/liquid/tags/raw.rb +50 -11
- data/lib/liquid/tags/render.rb +109 -0
- data/lib/liquid/tags/table_row.rb +88 -0
- data/lib/liquid/tags/unless.rb +37 -21
- data/lib/liquid/template.rb +124 -46
- data/lib/liquid/template_factory.rb +9 -0
- data/lib/liquid/tokenizer.rb +39 -0
- data/lib/liquid/usage.rb +8 -0
- data/lib/liquid/utils.rb +68 -5
- data/lib/liquid/variable.rb +128 -32
- data/lib/liquid/variable_lookup.rb +96 -0
- data/lib/liquid/version.rb +3 -1
- data/lib/liquid.rb +36 -13
- metadata +69 -77
- data/lib/extras/liquid_view.rb +0 -51
- data/lib/liquid/htmltags.rb +0 -73
- data/lib/liquid/module_ex.rb +0 -62
- data/lib/liquid/strainer.rb +0 -53
- data/test/liquid/assign_test.rb +0 -21
- data/test/liquid/block_test.rb +0 -58
- data/test/liquid/capture_test.rb +0 -40
- data/test/liquid/condition_test.rb +0 -127
- data/test/liquid/context_test.rb +0 -478
- data/test/liquid/drop_test.rb +0 -180
- data/test/liquid/error_handling_test.rb +0 -81
- data/test/liquid/file_system_test.rb +0 -29
- data/test/liquid/filter_test.rb +0 -125
- data/test/liquid/hash_ordering_test.rb +0 -25
- data/test/liquid/module_ex_test.rb +0 -87
- data/test/liquid/output_test.rb +0 -116
- data/test/liquid/parsing_quirks_test.rb +0 -52
- data/test/liquid/regexp_test.rb +0 -44
- data/test/liquid/security_test.rb +0 -64
- data/test/liquid/standard_filter_test.rb +0 -263
- data/test/liquid/strainer_test.rb +0 -52
- data/test/liquid/tags/break_tag_test.rb +0 -16
- data/test/liquid/tags/continue_tag_test.rb +0 -16
- data/test/liquid/tags/for_tag_test.rb +0 -297
- data/test/liquid/tags/html_tag_test.rb +0 -63
- data/test/liquid/tags/if_else_tag_test.rb +0 -166
- data/test/liquid/tags/include_tag_test.rb +0 -166
- data/test/liquid/tags/increment_tag_test.rb +0 -24
- data/test/liquid/tags/raw_tag_test.rb +0 -24
- data/test/liquid/tags/standard_tag_test.rb +0 -295
- data/test/liquid/tags/statements_test.rb +0 -134
- data/test/liquid/tags/unless_else_tag_test.rb +0 -26
- data/test/liquid/template_test.rb +0 -146
- data/test/liquid/variable_test.rb +0 -186
- data/test/test_helper.rb +0 -29
- /data/{MIT-LICENSE → LICENSE} +0 -0
data/lib/liquid/variable.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
module Liquid
|
3
4
|
# Holds variables. Variables are only loaded "just in time"
|
4
5
|
# and are not evaluated as part of the render stage
|
5
6
|
#
|
@@ -11,46 +12,141 @@ module Liquid
|
|
11
12
|
# {{ user | link }}
|
12
13
|
#
|
13
14
|
class Variable
|
14
|
-
|
15
|
-
|
15
|
+
FilterMarkupRegex = /#{FilterSeparator}\s*(.*)/om
|
16
|
+
FilterParser = /(?:\s+|#{QuotedFragment}|#{ArgumentSeparator})+/o
|
17
|
+
FilterArgsRegex = /(?:#{FilterArgumentSeparator}|#{ArgumentSeparator})\s*((?:\w+\s*\:\s*)?#{QuotedFragment})/o
|
18
|
+
JustTagAttributes = /\A#{TagAttributes}\z/o
|
19
|
+
MarkupWithQuotedFragment = /(#{QuotedFragment})(.*)/om
|
20
|
+
|
21
|
+
attr_accessor :filters, :name, :line_number
|
22
|
+
attr_reader :parse_context
|
23
|
+
alias_method :options, :parse_context
|
24
|
+
|
25
|
+
include ParserSwitching
|
26
|
+
|
27
|
+
def initialize(markup, parse_context)
|
28
|
+
@markup = markup
|
29
|
+
@name = nil
|
30
|
+
@parse_context = parse_context
|
31
|
+
@line_number = parse_context.line_number
|
32
|
+
|
33
|
+
strict_parse_with_error_mode_fallback(markup)
|
34
|
+
end
|
35
|
+
|
36
|
+
def raw
|
37
|
+
@markup
|
38
|
+
end
|
39
|
+
|
40
|
+
def markup_context(markup)
|
41
|
+
"in \"{{#{markup}}}\""
|
42
|
+
end
|
16
43
|
|
17
|
-
def
|
18
|
-
@markup = markup
|
19
|
-
@name = nil
|
44
|
+
def lax_parse(markup)
|
20
45
|
@filters = []
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
46
|
+
return unless markup =~ MarkupWithQuotedFragment
|
47
|
+
|
48
|
+
name_markup = Regexp.last_match(1)
|
49
|
+
filter_markup = Regexp.last_match(2)
|
50
|
+
@name = parse_context.parse_expression(name_markup)
|
51
|
+
if filter_markup =~ FilterMarkupRegex
|
52
|
+
filters = Regexp.last_match(1).scan(FilterParser)
|
53
|
+
filters.each do |f|
|
54
|
+
next unless f =~ /\w+/
|
55
|
+
filtername = Regexp.last_match(0)
|
56
|
+
filterargs = f.scan(FilterArgsRegex).flatten
|
57
|
+
@filters << parse_filter_expressions(filtername, filterargs)
|
32
58
|
end
|
33
59
|
end
|
34
60
|
end
|
35
61
|
|
62
|
+
def strict_parse(markup)
|
63
|
+
@filters = []
|
64
|
+
p = Parser.new(markup)
|
65
|
+
|
66
|
+
return if p.look(:end_of_string)
|
67
|
+
|
68
|
+
@name = parse_context.parse_expression(p.expression)
|
69
|
+
while p.consume?(:pipe)
|
70
|
+
filtername = p.consume(:id)
|
71
|
+
filterargs = p.consume?(:colon) ? parse_filterargs(p) : []
|
72
|
+
@filters << parse_filter_expressions(filtername, filterargs)
|
73
|
+
end
|
74
|
+
p.consume(:end_of_string)
|
75
|
+
end
|
76
|
+
|
77
|
+
def parse_filterargs(p)
|
78
|
+
# first argument
|
79
|
+
filterargs = [p.argument]
|
80
|
+
# followed by comma separated others
|
81
|
+
filterargs << p.argument while p.consume?(:comma)
|
82
|
+
filterargs
|
83
|
+
end
|
84
|
+
|
36
85
|
def render(context)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
86
|
+
obj = context.evaluate(@name)
|
87
|
+
|
88
|
+
@filters.each do |filter_name, filter_args, filter_kwargs|
|
89
|
+
filter_args = evaluate_filter_expressions(context, filter_args, filter_kwargs)
|
90
|
+
obj = context.invoke(filter_name, obj, *filter_args)
|
91
|
+
end
|
92
|
+
|
93
|
+
context.apply_global_filter(obj)
|
94
|
+
end
|
95
|
+
|
96
|
+
def render_to_output_buffer(context, output)
|
97
|
+
obj = render(context)
|
98
|
+
|
99
|
+
if obj.is_a?(Array)
|
100
|
+
output << obj.join
|
101
|
+
elsif obj.nil?
|
102
|
+
else
|
103
|
+
output << obj.to_s
|
104
|
+
end
|
105
|
+
|
106
|
+
output
|
107
|
+
end
|
108
|
+
|
109
|
+
def disabled?(_context)
|
110
|
+
false
|
111
|
+
end
|
112
|
+
|
113
|
+
def disabled_tags
|
114
|
+
[]
|
115
|
+
end
|
116
|
+
|
117
|
+
private
|
118
|
+
|
119
|
+
def parse_filter_expressions(filter_name, unparsed_args)
|
120
|
+
filter_args = []
|
121
|
+
keyword_args = nil
|
122
|
+
unparsed_args.each do |a|
|
123
|
+
if (matches = a.match(JustTagAttributes))
|
124
|
+
keyword_args ||= {}
|
125
|
+
keyword_args[matches[1]] = parse_context.parse_expression(matches[2])
|
126
|
+
else
|
127
|
+
filter_args << parse_context.parse_expression(a)
|
47
128
|
end
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
129
|
+
end
|
130
|
+
result = [filter_name, filter_args]
|
131
|
+
result << keyword_args if keyword_args
|
132
|
+
result
|
133
|
+
end
|
134
|
+
|
135
|
+
def evaluate_filter_expressions(context, filter_args, filter_kwargs)
|
136
|
+
parsed_args = filter_args.map { |expr| context.evaluate(expr) }
|
137
|
+
if filter_kwargs
|
138
|
+
parsed_kwargs = {}
|
139
|
+
filter_kwargs.each do |key, expr|
|
140
|
+
parsed_kwargs[key] = context.evaluate(expr)
|
53
141
|
end
|
142
|
+
parsed_args << parsed_kwargs
|
143
|
+
end
|
144
|
+
parsed_args
|
145
|
+
end
|
146
|
+
|
147
|
+
class ParseTreeVisitor < Liquid::ParseTreeVisitor
|
148
|
+
def children
|
149
|
+
[@node.name] + @node.filters.flatten
|
54
150
|
end
|
55
151
|
end
|
56
152
|
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Liquid
|
4
|
+
class VariableLookup
|
5
|
+
COMMAND_METHODS = ['size', 'first', 'last'].freeze
|
6
|
+
|
7
|
+
attr_reader :name, :lookups
|
8
|
+
|
9
|
+
def self.parse(markup)
|
10
|
+
new(markup)
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(markup)
|
14
|
+
lookups = markup.scan(VariableParser)
|
15
|
+
|
16
|
+
name = lookups.shift
|
17
|
+
if name&.start_with?('[') && name&.end_with?(']')
|
18
|
+
name = Expression.parse(name[1..-2])
|
19
|
+
end
|
20
|
+
@name = name
|
21
|
+
|
22
|
+
@lookups = lookups
|
23
|
+
@command_flags = 0
|
24
|
+
|
25
|
+
@lookups.each_index do |i|
|
26
|
+
lookup = lookups[i]
|
27
|
+
if lookup&.start_with?('[') && lookup&.end_with?(']')
|
28
|
+
lookups[i] = Expression.parse(lookup[1..-2])
|
29
|
+
elsif COMMAND_METHODS.include?(lookup)
|
30
|
+
@command_flags |= 1 << i
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def lookup_command?(lookup_index)
|
36
|
+
@command_flags & (1 << lookup_index) != 0
|
37
|
+
end
|
38
|
+
|
39
|
+
def evaluate(context)
|
40
|
+
name = context.evaluate(@name)
|
41
|
+
object = context.find_variable(name)
|
42
|
+
|
43
|
+
@lookups.each_index do |i|
|
44
|
+
key = context.evaluate(@lookups[i])
|
45
|
+
|
46
|
+
# Cast "key" to its liquid value to enable it to act as a primitive value
|
47
|
+
key = Liquid::Utils.to_liquid_value(key)
|
48
|
+
|
49
|
+
# If object is a hash- or array-like object we look for the
|
50
|
+
# presence of the key and if its available we return it
|
51
|
+
if object.respond_to?(:[]) &&
|
52
|
+
((object.respond_to?(:key?) && object.key?(key)) ||
|
53
|
+
(object.respond_to?(:fetch) && key.is_a?(Integer)))
|
54
|
+
|
55
|
+
# if its a proc we will replace the entry with the proc
|
56
|
+
res = context.lookup_and_evaluate(object, key)
|
57
|
+
object = res.to_liquid
|
58
|
+
|
59
|
+
# Some special cases. If the part wasn't in square brackets and
|
60
|
+
# no key with the same name was found we interpret following calls
|
61
|
+
# as commands and call them on the current object
|
62
|
+
elsif lookup_command?(i) && object.respond_to?(key)
|
63
|
+
object = object.send(key).to_liquid
|
64
|
+
|
65
|
+
# No key was present with the desired value and it wasn't one of the directly supported
|
66
|
+
# keywords either. The only thing we got left is to return nil or
|
67
|
+
# raise an exception if `strict_variables` option is set to true
|
68
|
+
else
|
69
|
+
return nil unless context.strict_variables
|
70
|
+
raise Liquid::UndefinedVariable, "undefined variable #{key}"
|
71
|
+
end
|
72
|
+
|
73
|
+
# If we are dealing with a drop here we have to
|
74
|
+
object.context = context if object.respond_to?(:context=)
|
75
|
+
end
|
76
|
+
|
77
|
+
object
|
78
|
+
end
|
79
|
+
|
80
|
+
def ==(other)
|
81
|
+
self.class == other.class && state == other.state
|
82
|
+
end
|
83
|
+
|
84
|
+
protected
|
85
|
+
|
86
|
+
def state
|
87
|
+
[@name, @lookups, @command_flags]
|
88
|
+
end
|
89
|
+
|
90
|
+
class ParseTreeVisitor < Liquid::ParseTreeVisitor
|
91
|
+
def children
|
92
|
+
@node.lookups
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
data/lib/liquid/version.rb
CHANGED
data/lib/liquid.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright (c) 2005 Tobias Luetke
|
2
4
|
#
|
3
5
|
# Permission is hereby granted, free of charge, to any person obtaining
|
@@ -24,8 +26,10 @@ module Liquid
|
|
24
26
|
ArgumentSeparator = ','
|
25
27
|
FilterArgumentSeparator = ':'
|
26
28
|
VariableAttributeSeparator = '.'
|
29
|
+
WhitespaceControl = '-'
|
27
30
|
TagStart = /\{\%/
|
28
31
|
TagEnd = /\%\}/
|
32
|
+
TagName = /#|\w+/
|
29
33
|
VariableSignature = /\(?[\w\-\.\[\]]\)?/
|
30
34
|
VariableSegment = /[\w\-]/
|
31
35
|
VariableStart = /\{\{/
|
@@ -33,37 +37,56 @@ module Liquid
|
|
33
37
|
VariableIncompleteEnd = /\}\}?/
|
34
38
|
QuotedString = /"[^"]*"|'[^']*'/
|
35
39
|
QuotedFragment = /#{QuotedString}|(?:[^\s,\|'"]|#{QuotedString})+/o
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
Expression = /(?:#{QuotedFragment}(?:#{SpacelessFilter})*)/o
|
41
|
-
TagAttributes = /(\w+)\s*\:\s*(#{QuotedFragment})/o
|
42
|
-
AnyStartingTag = /\{\{|\{\%/
|
43
|
-
PartialTemplateParser = /#{TagStart}.*?#{TagEnd}|#{VariableStart}.*?#{VariableIncompleteEnd}/o
|
44
|
-
TemplateParser = /(#{PartialTemplateParser}|#{AnyStartingTag})/o
|
40
|
+
TagAttributes = /(\w[\w-]*)\s*\:\s*(#{QuotedFragment})/o
|
41
|
+
AnyStartingTag = /#{TagStart}|#{VariableStart}/o
|
42
|
+
PartialTemplateParser = /#{TagStart}.*?#{TagEnd}|#{VariableStart}.*?#{VariableIncompleteEnd}/om
|
43
|
+
TemplateParser = /(#{PartialTemplateParser}|#{AnyStartingTag})/om
|
45
44
|
VariableParser = /\[[^\]]+\]|#{VariableSegment}+\??/o
|
45
|
+
|
46
|
+
RAISE_EXCEPTION_LAMBDA = ->(_e) { raise }
|
47
|
+
|
48
|
+
singleton_class.send(:attr_accessor, :cache_classes)
|
49
|
+
self.cache_classes = true
|
46
50
|
end
|
47
51
|
|
48
52
|
require "liquid/version"
|
53
|
+
require 'liquid/parse_tree_visitor'
|
54
|
+
require 'liquid/lexer'
|
55
|
+
require 'liquid/parser'
|
56
|
+
require 'liquid/i18n'
|
49
57
|
require 'liquid/drop'
|
58
|
+
require 'liquid/tablerowloop_drop'
|
59
|
+
require 'liquid/forloop_drop'
|
50
60
|
require 'liquid/extensions'
|
51
61
|
require 'liquid/errors'
|
52
62
|
require 'liquid/interrupts'
|
53
|
-
require 'liquid/
|
63
|
+
require 'liquid/strainer_template'
|
64
|
+
require 'liquid/strainer_factory'
|
65
|
+
require 'liquid/expression'
|
54
66
|
require 'liquid/context'
|
67
|
+
require 'liquid/parser_switching'
|
55
68
|
require 'liquid/tag'
|
69
|
+
require 'liquid/tag/disabler'
|
70
|
+
require 'liquid/tag/disableable'
|
56
71
|
require 'liquid/block'
|
72
|
+
require 'liquid/block_body'
|
57
73
|
require 'liquid/document'
|
58
74
|
require 'liquid/variable'
|
75
|
+
require 'liquid/variable_lookup'
|
76
|
+
require 'liquid/range_lookup'
|
59
77
|
require 'liquid/file_system'
|
78
|
+
require 'liquid/resource_limits'
|
60
79
|
require 'liquid/template'
|
61
|
-
require 'liquid/htmltags'
|
62
80
|
require 'liquid/standardfilters'
|
63
81
|
require 'liquid/condition'
|
64
|
-
require 'liquid/module_ex'
|
65
82
|
require 'liquid/utils'
|
83
|
+
require 'liquid/tokenizer'
|
84
|
+
require 'liquid/parse_context'
|
85
|
+
require 'liquid/partial_cache'
|
86
|
+
require 'liquid/usage'
|
87
|
+
require 'liquid/registers'
|
88
|
+
require 'liquid/template_factory'
|
66
89
|
|
67
90
|
# Load all the tags of the standard library
|
68
91
|
#
|
69
|
-
Dir[
|
92
|
+
Dir["#{__dir__}/liquid/tags/*.rb"].each { |f| require f }
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liquid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Tobias
|
7
|
+
- Tobias Lütke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
11
|
+
date: 2022-07-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '13.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '13.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
description:
|
14
42
|
email:
|
15
43
|
- tobi@leetsoft.com
|
@@ -20,24 +48,41 @@ extra_rdoc_files:
|
|
20
48
|
- README.md
|
21
49
|
files:
|
22
50
|
- History.md
|
23
|
-
-
|
51
|
+
- LICENSE
|
24
52
|
- README.md
|
25
|
-
- lib/extras/liquid_view.rb
|
26
53
|
- lib/liquid.rb
|
27
54
|
- lib/liquid/block.rb
|
55
|
+
- lib/liquid/block_body.rb
|
28
56
|
- lib/liquid/condition.rb
|
29
57
|
- lib/liquid/context.rb
|
30
58
|
- lib/liquid/document.rb
|
31
59
|
- lib/liquid/drop.rb
|
32
60
|
- lib/liquid/errors.rb
|
61
|
+
- lib/liquid/expression.rb
|
33
62
|
- lib/liquid/extensions.rb
|
34
63
|
- lib/liquid/file_system.rb
|
35
|
-
- lib/liquid/
|
64
|
+
- lib/liquid/forloop_drop.rb
|
65
|
+
- lib/liquid/i18n.rb
|
36
66
|
- lib/liquid/interrupts.rb
|
37
|
-
- lib/liquid/
|
67
|
+
- lib/liquid/lexer.rb
|
68
|
+
- lib/liquid/locales/en.yml
|
69
|
+
- lib/liquid/parse_context.rb
|
70
|
+
- lib/liquid/parse_tree_visitor.rb
|
71
|
+
- lib/liquid/parser.rb
|
72
|
+
- lib/liquid/parser_switching.rb
|
73
|
+
- lib/liquid/partial_cache.rb
|
74
|
+
- lib/liquid/profiler.rb
|
75
|
+
- lib/liquid/profiler/hooks.rb
|
76
|
+
- lib/liquid/range_lookup.rb
|
77
|
+
- lib/liquid/registers.rb
|
78
|
+
- lib/liquid/resource_limits.rb
|
38
79
|
- lib/liquid/standardfilters.rb
|
39
|
-
- lib/liquid/
|
80
|
+
- lib/liquid/strainer_factory.rb
|
81
|
+
- lib/liquid/strainer_template.rb
|
82
|
+
- lib/liquid/tablerowloop_drop.rb
|
40
83
|
- lib/liquid/tag.rb
|
84
|
+
- lib/liquid/tag/disableable.rb
|
85
|
+
- lib/liquid/tag/disabler.rb
|
41
86
|
- lib/liquid/tags/assign.rb
|
42
87
|
- lib/liquid/tags/break.rb
|
43
88
|
- lib/liquid/tags/capture.rb
|
@@ -46,51 +91,30 @@ files:
|
|
46
91
|
- lib/liquid/tags/continue.rb
|
47
92
|
- lib/liquid/tags/cycle.rb
|
48
93
|
- lib/liquid/tags/decrement.rb
|
94
|
+
- lib/liquid/tags/echo.rb
|
49
95
|
- lib/liquid/tags/for.rb
|
50
96
|
- lib/liquid/tags/if.rb
|
51
97
|
- lib/liquid/tags/ifchanged.rb
|
52
98
|
- lib/liquid/tags/include.rb
|
53
99
|
- lib/liquid/tags/increment.rb
|
100
|
+
- lib/liquid/tags/inline_comment.rb
|
54
101
|
- lib/liquid/tags/raw.rb
|
102
|
+
- lib/liquid/tags/render.rb
|
103
|
+
- lib/liquid/tags/table_row.rb
|
55
104
|
- lib/liquid/tags/unless.rb
|
56
105
|
- lib/liquid/template.rb
|
106
|
+
- lib/liquid/template_factory.rb
|
107
|
+
- lib/liquid/tokenizer.rb
|
108
|
+
- lib/liquid/usage.rb
|
57
109
|
- lib/liquid/utils.rb
|
58
110
|
- lib/liquid/variable.rb
|
111
|
+
- lib/liquid/variable_lookup.rb
|
59
112
|
- lib/liquid/version.rb
|
60
|
-
- test/liquid/assign_test.rb
|
61
|
-
- test/liquid/block_test.rb
|
62
|
-
- test/liquid/capture_test.rb
|
63
|
-
- test/liquid/condition_test.rb
|
64
|
-
- test/liquid/context_test.rb
|
65
|
-
- test/liquid/drop_test.rb
|
66
|
-
- test/liquid/error_handling_test.rb
|
67
|
-
- test/liquid/file_system_test.rb
|
68
|
-
- test/liquid/filter_test.rb
|
69
|
-
- test/liquid/hash_ordering_test.rb
|
70
|
-
- test/liquid/module_ex_test.rb
|
71
|
-
- test/liquid/output_test.rb
|
72
|
-
- test/liquid/parsing_quirks_test.rb
|
73
|
-
- test/liquid/regexp_test.rb
|
74
|
-
- test/liquid/security_test.rb
|
75
|
-
- test/liquid/standard_filter_test.rb
|
76
|
-
- test/liquid/strainer_test.rb
|
77
|
-
- test/liquid/tags/break_tag_test.rb
|
78
|
-
- test/liquid/tags/continue_tag_test.rb
|
79
|
-
- test/liquid/tags/for_tag_test.rb
|
80
|
-
- test/liquid/tags/html_tag_test.rb
|
81
|
-
- test/liquid/tags/if_else_tag_test.rb
|
82
|
-
- test/liquid/tags/include_tag_test.rb
|
83
|
-
- test/liquid/tags/increment_tag_test.rb
|
84
|
-
- test/liquid/tags/raw_tag_test.rb
|
85
|
-
- test/liquid/tags/standard_tag_test.rb
|
86
|
-
- test/liquid/tags/statements_test.rb
|
87
|
-
- test/liquid/tags/unless_else_tag_test.rb
|
88
|
-
- test/liquid/template_test.rb
|
89
|
-
- test/liquid/variable_test.rb
|
90
|
-
- test/test_helper.rb
|
91
113
|
homepage: http://www.liquidmarkup.org
|
92
|
-
licenses:
|
93
|
-
|
114
|
+
licenses:
|
115
|
+
- MIT
|
116
|
+
metadata:
|
117
|
+
allowed_push_host: https://rubygems.org
|
94
118
|
post_install_message:
|
95
119
|
rdoc_options: []
|
96
120
|
require_paths:
|
@@ -99,47 +123,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
123
|
requirements:
|
100
124
|
- - ">="
|
101
125
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
126
|
+
version: 2.7.0
|
103
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
128
|
requirements:
|
105
129
|
- - ">="
|
106
130
|
- !ruby/object:Gem::Version
|
107
131
|
version: 1.3.7
|
108
132
|
requirements: []
|
109
|
-
|
110
|
-
rubygems_version: 2.2.3
|
133
|
+
rubygems_version: 3.3.3
|
111
134
|
signing_key:
|
112
135
|
specification_version: 4
|
113
136
|
summary: A secure, non-evaling end user template engine with aesthetic markup.
|
114
|
-
test_files:
|
115
|
-
- test/liquid/assign_test.rb
|
116
|
-
- test/liquid/block_test.rb
|
117
|
-
- test/liquid/capture_test.rb
|
118
|
-
- test/liquid/condition_test.rb
|
119
|
-
- test/liquid/context_test.rb
|
120
|
-
- test/liquid/drop_test.rb
|
121
|
-
- test/liquid/error_handling_test.rb
|
122
|
-
- test/liquid/file_system_test.rb
|
123
|
-
- test/liquid/filter_test.rb
|
124
|
-
- test/liquid/hash_ordering_test.rb
|
125
|
-
- test/liquid/module_ex_test.rb
|
126
|
-
- test/liquid/output_test.rb
|
127
|
-
- test/liquid/parsing_quirks_test.rb
|
128
|
-
- test/liquid/regexp_test.rb
|
129
|
-
- test/liquid/security_test.rb
|
130
|
-
- test/liquid/standard_filter_test.rb
|
131
|
-
- test/liquid/strainer_test.rb
|
132
|
-
- test/liquid/tags/break_tag_test.rb
|
133
|
-
- test/liquid/tags/continue_tag_test.rb
|
134
|
-
- test/liquid/tags/for_tag_test.rb
|
135
|
-
- test/liquid/tags/html_tag_test.rb
|
136
|
-
- test/liquid/tags/if_else_tag_test.rb
|
137
|
-
- test/liquid/tags/include_tag_test.rb
|
138
|
-
- test/liquid/tags/increment_tag_test.rb
|
139
|
-
- test/liquid/tags/raw_tag_test.rb
|
140
|
-
- test/liquid/tags/standard_tag_test.rb
|
141
|
-
- test/liquid/tags/statements_test.rb
|
142
|
-
- test/liquid/tags/unless_else_tag_test.rb
|
143
|
-
- test/liquid/template_test.rb
|
144
|
-
- test/liquid/variable_test.rb
|
145
|
-
- test/test_helper.rb
|
137
|
+
test_files: []
|
data/lib/extras/liquid_view.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
# LiquidView is a action view extension class. You can register it with rails
|
2
|
-
# and use liquid as an template system for .liquid files
|
3
|
-
#
|
4
|
-
# Example
|
5
|
-
#
|
6
|
-
# ActionView::Base::register_template_handler :liquid, LiquidView
|
7
|
-
class LiquidView
|
8
|
-
PROTECTED_ASSIGNS = %w( template_root response _session template_class action_name request_origin session template
|
9
|
-
_response url _request _cookies variables_added _flash params _headers request cookies
|
10
|
-
ignore_missing_templates flash _params logger before_filter_chain_aborted headers )
|
11
|
-
PROTECTED_INSTANCE_VARIABLES = %w( @_request @controller @_first_render @_memoized__pick_template @view_paths
|
12
|
-
@helpers @assigns_added @template @_render_stack @template_format @assigns )
|
13
|
-
|
14
|
-
def self.call(template)
|
15
|
-
"LiquidView.new(self).render(template, local_assigns)"
|
16
|
-
end
|
17
|
-
|
18
|
-
def initialize(view)
|
19
|
-
@view = view
|
20
|
-
end
|
21
|
-
|
22
|
-
def render(template, local_assigns = nil)
|
23
|
-
@view.controller.headers["Content-Type"] ||= 'text/html; charset=utf-8'
|
24
|
-
|
25
|
-
# Rails 2.2 Template has source, but not locals
|
26
|
-
if template.respond_to?(:source) && !template.respond_to?(:locals)
|
27
|
-
assigns = (@view.instance_variables - PROTECTED_INSTANCE_VARIABLES).inject({}) do |hash, ivar|
|
28
|
-
hash[ivar[1..-1]] = @view.instance_variable_get(ivar)
|
29
|
-
hash
|
30
|
-
end
|
31
|
-
else
|
32
|
-
assigns = @view.assigns.reject{ |k,v| PROTECTED_ASSIGNS.include?(k) }
|
33
|
-
end
|
34
|
-
|
35
|
-
source = template.respond_to?(:source) ? template.source : template
|
36
|
-
local_assigns = (template.respond_to?(:locals) ? template.locals : local_assigns) || {}
|
37
|
-
|
38
|
-
if content_for_layout = @view.instance_variable_get("@content_for_layout")
|
39
|
-
assigns['content_for_layout'] = content_for_layout
|
40
|
-
end
|
41
|
-
assigns.merge!(local_assigns.stringify_keys)
|
42
|
-
|
43
|
-
liquid = Liquid::Template.parse(source)
|
44
|
-
liquid.render(assigns, :filters => [@view.controller.master_helper_module], :registers => {:action_view => @view, :controller => @view.controller})
|
45
|
-
end
|
46
|
-
|
47
|
-
def compilable?
|
48
|
-
false
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|