Sha256: 5e1b86afa47764812e2579f1de803d014cedde2b98c0c5f45f3183b3ab93cf75
Contents?: true
Size: 1.1 KB
Versions: 5
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true module Liquid class Raw < Block Syntax = /\A\s*\z/ FullTokenPossiblyInvalid = /\A(.*)#{TagStart}\s*(\w+)\s*(.*)?#{TagEnd}\z/om def initialize(tag_name, markup, parse_context) super ensure_valid_markup(tag_name, markup, parse_context) end def parse(tokens) @body = +'' while (token = tokens.shift) if token =~ FullTokenPossiblyInvalid && block_delimiter == Regexp.last_match(2) @body << Regexp.last_match(1) if Regexp.last_match(1) != "" return end @body << token unless token.empty? end raise_tag_never_closed(block_name) end def render_to_output_buffer(_context, output) output << @body output end def nodelist [@body] end def blank? @body.empty? end protected def ensure_valid_markup(tag_name, markup, parse_context) unless Syntax.match?(markup) raise SyntaxError, parse_context.locale.t("errors.syntax.tag_unexpected_args", tag: tag_name) end end end Template.register_tag('raw', Raw) end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
liquid-5.3.0 | lib/liquid/tags/raw.rb |
liquid-5.2.0 | lib/liquid/tags/raw.rb |
liquid-5.1.0 | lib/liquid/tags/raw.rb |
liquid-5.0.1 | lib/liquid/tags/raw.rb |
liquid-5.0.0 | lib/liquid/tags/raw.rb |