Sha256: 2605bfacef3cf1f6f157584ebd886c3fde6b50d2ae013e3da87b02e725a80274

Contents?: true

Size: 939 Bytes

Versions: 2

Compression:

Stored size: 939 Bytes

Contents

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

      unless markup =~ Syntax
        raise SyntaxError.new(parse_context.locale.t("errors.syntax.tag_unexpected_args".freeze, tag: tag_name))
      end
    end

    def parse(tokens)
      @body = ''
      while token = tokens.shift
        if token =~ FullTokenPossiblyInvalid
          @body << $1 if $1 != "".freeze
          return if block_delimiter == $2
        end
        @body << token unless token.empty?
      end

      raise SyntaxError.new(parse_context.locale.t("errors.syntax.tag_never_closed".freeze, block_name: block_name))
    end

    def render(_context)
      @body
    end

    def nodelist
      [@body]
    end

    def blank?
      @body.empty?
    end
  end

  Template.register_tag('raw'.freeze, Raw)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
liquid-4.0.0.rc2 lib/liquid/tags/raw.rb
liquid-4.0.0.rc1 lib/liquid/tags/raw.rb