Sha256: 30c99bdb16abb377be5f88a19c60ef1d9b9c785f9b24d3302cdcb6ccd6835d72

Contents?: true

Size: 1.14 KB

Versions: 35

Compression:

Stored size: 1.14 KB

Contents

module Liquid

  class Literal < Block

    # Class methods

    # Converts a shorthand Liquid literal into its long representation.
    #
    # Currently the Template parser only knows how to handle the long version.
    # So, it always checks if it is in the presence of a literal, in which case it gets converted through this method.
    #
    # Example:
    #   Liquid::Literal "{{{ hello world }}}" #=> "{% literal %} hello world {% endliteral %}"
    def self.from_shorthand(literal)
      literal =~ LiteralShorthand ? "{% literal %}#{$1}{% endliteral %}" : literal
    end

    # Public instance methods

    def parse(tokens) # :nodoc:
      @nodelist ||= []
      @nodelist.clear

      while token = tokens.shift
        if token =~ FullToken && block_delimiter == $1
          end_tag
          return
        else
          @nodelist << token
        end
      end

      # Make sure that its ok to end parsing in the current block.
      # Effectively this method will throw and exception unless the current block is
      # of type Document
      assert_missing_delimitation!
    end # parse

  end

  Template.register_tag('literal', Literal)
end

Version data entries

35 entries across 35 versions & 5 rubygems

Version Path
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/liquid-2.2.2/lib/liquid/tags/literal.rb
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/liquid-2.2.2/lib/liquid/tags/literal.rb
locomotive_liquid-2.2.3 lib/liquid/tags/literal.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/liquid-2.2.2/lib/liquid/tags/literal.rb
liquid_cms-0.3.2.0 lib/generators/liquid_cms/templates/vendor/plugins/liquid/lib/liquid/tags/literal.rb
liquid_cms-0.2.2.0 generators/liquid_cms/templates/vendor/plugins/cms_plugins/liquid/lib/liquid/tags/literal.rb
liquid_cms-0.2.1.1 generators/liquid_cms/templates/vendor/plugins/cms_plugins/liquid/lib/liquid/tags/literal.rb
liquid_cms-0.3.1.0 lib/generators/liquid_cms/templates/vendor/plugins/liquid/lib/liquid/tags/literal.rb
liquid_cms-0.2.1.0 generators/liquid_cms/templates/vendor/plugins/cms_plugins/liquid/lib/liquid/tags/literal.rb
liquid_cms-0.2.0.13 generators/liquid_cms/templates/vendor/plugins/cms_plugins/liquid/lib/liquid/tags/literal.rb
liquid_cms-0.3.0.10 lib/generators/liquid_cms/templates/vendor/plugins/liquid/lib/liquid/tags/literal.rb
liquid_cms-0.3.0.9 lib/generators/liquid_cms/templates/vendor/plugins/liquid/lib/liquid/tags/literal.rb
liquid_cms-0.2.0.12 generators/liquid_cms/templates/vendor/plugins/cms_plugins/liquid/lib/liquid/tags/literal.rb
liquid_cms-0.2.0.11 generators/liquid_cms/templates/vendor/plugins/cms_plugins/liquid/lib/liquid/tags/literal.rb
liquid_cms-0.2.0.10 generators/liquid_cms/templates/vendor/plugins/cms_plugins/liquid/lib/liquid/tags/literal.rb
liquid_cms-0.3.0.8 lib/generators/liquid_cms/templates/vendor/plugins/liquid/lib/liquid/tags/literal.rb
liquid_cms-0.2.0.9 generators/liquid_cms/templates/vendor/plugins/cms_plugins/liquid/lib/liquid/tags/literal.rb
liquid_cms-0.3.0.7 lib/generators/liquid_cms/templates/vendor/plugins/liquid/lib/liquid/tags/literal.rb
liquid_cms-0.3.0.6 lib/generators/liquid_cms/templates/vendor/plugins/liquid/lib/liquid/tags/literal.rb
liquid_cms-0.2.0.8 generators/liquid_cms/templates/vendor/plugins/cms_plugins/liquid/lib/liquid/tags/literal.rb