working with default parsing for args

This commit is contained in:
Josh Faigan
2024-09-27 12:29:03 -04:00
parent 30ea917a38
commit 98a69c80ef
4 changed files with 59 additions and 7 deletions
+7 -1
View File
@@ -68,7 +68,13 @@ module Liquid
# Inline snippets take precedence over external snippets
if (inline_snippet = context.registers[:inline_snippet][template_name])
return output << inline_snippet.render(context)
inner_context = context.new_isolated_subcontext
@attributes.each do |key, value|
inner_context[key] = context.evaluate(value)
end
return output << inline_snippet.render(inner_context)
end
partial = PartialCache.load(
+8 -2
View File
@@ -14,12 +14,17 @@ module Liquid
# value
# {% endsnippet %}
class Snippet < Block
# SYNTAX = /(#{QuotedString}+) +\|(#{VariableSegment}*)\|/o
SYNTAX = /(#{QuotedString}+)/o
def initialize(tag_name, markup, options)
super
if markup =~ SYNTAX
# binding.irb
@to = Regexp.last_match(1)
# arg = Regexp.last_match(2)
# @args = []
# @args << arg if arg
else
raise SyntaxError, options[:locale].t("errors.syntax.snippet")
end
@@ -38,7 +43,8 @@ module Liquid
end
def snippet_body
@body
body = @body
body
end
end
end