Sha256: e05f3ef1940ea7724b805e09b140b55ce2eb17ef7988da7f920fb839d6ff1a9e

Contents?: true

Size: 1.39 KB

Versions: 31

Compression:

Stored size: 1.39 KB

Contents

# @Opulent
module Opulent
  # @Nodes
  module Nodes
    # @Text
    #
    # The text class will output raw or escaped HTML text
    #
    class Text
      # Allow direct access to literal value and type
      attr_accessor :value, :escaped, :parent, :indent, :name

      # Initialize literal instance variables
      #
      # @param value stores the literal's explicit value
      #
      def initialize(value = nil, escaped = true, parent = nil, indent = 0)
        @value = value
        @escaped = escaped
        @parent = parent
        @indent = indent
        @name = :text
      end

      # Value evaluation method which returns the processed value of the
      # literal
      #
      def evaluate(context)
        value = context.evaluate "\"#{@value}\""

        evaluated_text = self.dup
        evaluated_text.value = @escaped ? Runtime.escape(value) : value
        return evaluated_text
      end
    end

    # @Print
    #
    # The print class will evaluate the ruby code and return a new text
    # node containing the escaped or unescaped eval sequence
    #
    class Print < Text
      # Value evaluation method which returns the processed value of the literal
      #
      def evaluate(context)
        value = context.evaluate @value

        evaluated_text = self.dup
        evaluated_text.value = @escaped ? Runtime.escape(value) : value
        return evaluated_text
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
opulent-1.5.5 .libold/opulent/nodes/text.rb
opulent-1.5.4 .libold/opulent/nodes/text.rb
opulent-1.5.3 .libold/opulent/nodes/text.rb
opulent-1.5.2 .libold/opulent/nodes/text.rb
opulent-1.5.1 .libold/opulent/nodes/text.rb
opulent-1.5.0 .libold/opulent/nodes/text.rb
opulent-1.4.8 .libold/opulent/nodes/text.rb
opulent-1.4.7 .libold/opulent/nodes/text.rb
opulent-1.4.6 .libold/opulent/nodes/text.rb
opulent-1.4.5 .libold/opulent/nodes/text.rb
opulent-1.4.3 .libold/opulent/nodes/text.rb
opulent-1.4.2 .libold/opulent/nodes/text.rb
opulent-1.4.1 .libold/opulent/nodes/text.rb
opulent-1.4.0 .libold/opulent/nodes/text.rb
opulent-1.3.3 .libold/opulent/nodes/text.rb
opulent-1.3.2 .libold/opulent/nodes/text.rb
opulent-1.3.1 .libold/opulent/nodes/text.rb
opulent-1.3.0 .libold/opulent/nodes/text.rb
opulent-1.2.1 .libold/opulent/nodes/text.rb
opulent-1.2.0 .libold/opulent/nodes/text.rb