Compare commits

..

6 Commits

Author SHA1 Message Date
Sam Doiron
2d6bf406dd update grammar to support # 2021-01-29 17:06:16 -05:00
Sam Doiron
f331204f7c use Lua style syntax 2021-01-29 16:56:45 -05:00
Sam Doiron
5dcce427d0 Add inline comments syntax 2021-01-29 16:48:38 -05:00
Peter Zhu
3c499d0241 Merge pull request #1387 from Shopify/pz-serialize-benchmark-refactor
Refactor render_layout method for serialization
2021-01-11 15:51:00 -05:00
Peter Zhu
e71e53ffb5 Refactor render_layout method for serialization 2021-01-11 14:00:39 -05:00
Dylan Thacker-Smith
260c863e23 Build the tokenizer through the parse context for liquid-c (#1386) 2021-01-07 14:51:41 -05:00
4 changed files with 40 additions and 4 deletions

View File

@@ -4,7 +4,7 @@ require 'English'
module Liquid
class BlockBody
LiquidTagToken = /\A\s*(\w+)\s*(.*?)\z/o
LiquidTagToken = /\A\s*([\w#]+)\s*(.*?)\z/o
FullToken = /\A#{TagStart}#{WhitespaceControl}?(\s*)(\w+)(\s*)(.*?)#{WhitespaceControl}?#{TagEnd}\z/om
ContentOfVariable = /\A#{VariableStart}#{WhitespaceControl}?(.*?)#{WhitespaceControl}?#{VariableEnd}\z/om
WhitespaceOrNothing = /\A\s*\z/

View File

@@ -0,0 +1,15 @@
# frozen_string_literal: true
module Liquid
class InlineComment < Tag
def blank?
true
end
def render_to_output_buffer(_context, _output)
end
end
Template.register_tag('--', InlineComment)
end

View File

@@ -73,10 +73,14 @@ class ThemeRunner
private
def render_layout(template, layout, assigns)
assigns['content_for_layout'] = template.render!(assigns)
layout&.render!(assigns)
end
def compile_and_render(template, layout, assigns, page_template, template_file)
compiled_test = compile_test(template, layout, assigns, page_template, template_file)
assigns['content_for_layout'] = compiled_test[:tmpl].render!(assigns)
compiled_test[:layout].render!(assigns) if layout
compiled_test = compile_test(template, layout, assigns, page_template, template_file)
render_layout(compiled_test[:tmpl], compiled_test[:layout], compiled_test[:assigns])
end
def compile_all_tests

View File

@@ -0,0 +1,17 @@
# frozen_string_literal: true
require 'test_helper'
class InlineCommentTest < Minitest::Test
include Liquid
def test_basic_usage
template_source = <<-END_TEMPLATE
foo{% # this is a comment %}bar
END_TEMPLATE
template = Template.parse(template_source)
rendered = template.render!
assert_equal("foobar", rendered.strip)
end
end