Sha256: 604cc3bfe5f818578a91ecc9f3461d638c68165904bdabeedd584d5b70ac10ed

Contents?: true

Size: 602 Bytes

Versions: 3

Compression:

Stored size: 602 Bytes

Contents

# frozen_string_literal: true
require 'erb'

module Arbre
  module HTML

    class TextNode < Element

      builder_method :text_node

      # Builds a text node from a string
      def self.from_string(string)
        node = new
        node.build(string)
        node
      end

      def add_child(*args)
        raise "TextNodes do not have children"
      end

      def build(string)
        @content = string
      end

      def class_list
        []
      end

      def tag_name
        nil
      end

      def to_s
        ERB::Util.html_escape(@content.to_s)
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
arbre-1.7.0 lib/arbre/html/text_node.rb
arbre-1.6.0 lib/arbre/html/text_node.rb
arbre-1.5.0 lib/arbre/html/text_node.rb