mirror of
https://github.com/kemko/liquid.git
synced 2026-01-02 16:25:42 +03:00
Compare commits
6 Commits
parse-cont
...
inline-com
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d6bf406dd | ||
|
|
f331204f7c | ||
|
|
5dcce427d0 | ||
|
|
3c499d0241 | ||
|
|
e71e53ffb5 | ||
|
|
260c863e23 |
@@ -4,7 +4,7 @@ require 'English'
|
|||||||
|
|
||||||
module Liquid
|
module Liquid
|
||||||
class BlockBody
|
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
|
FullToken = /\A#{TagStart}#{WhitespaceControl}?(\s*)(\w+)(\s*)(.*?)#{WhitespaceControl}?#{TagEnd}\z/om
|
||||||
ContentOfVariable = /\A#{VariableStart}#{WhitespaceControl}?(.*?)#{WhitespaceControl}?#{VariableEnd}\z/om
|
ContentOfVariable = /\A#{VariableStart}#{WhitespaceControl}?(.*?)#{WhitespaceControl}?#{VariableEnd}\z/om
|
||||||
WhitespaceOrNothing = /\A\s*\z/
|
WhitespaceOrNothing = /\A\s*\z/
|
||||||
|
|||||||
15
lib/liquid/tags/inline_comment.rb
Normal file
15
lib/liquid/tags/inline_comment.rb
Normal 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
|
||||||
|
|
||||||
@@ -73,10 +73,14 @@ class ThemeRunner
|
|||||||
|
|
||||||
private
|
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)
|
def compile_and_render(template, layout, assigns, page_template, template_file)
|
||||||
compiled_test = compile_test(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)
|
render_layout(compiled_test[:tmpl], compiled_test[:layout], compiled_test[:assigns])
|
||||||
compiled_test[:layout].render!(assigns) if layout
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def compile_all_tests
|
def compile_all_tests
|
||||||
|
|||||||
17
test/integration/inline_comment_test.rb
Normal file
17
test/integration/inline_comment_test.rb
Normal 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
|
||||||
|
|
||||||
Reference in New Issue
Block a user