Sha256: 08344e3347d5a3241a81525b651c4bde9ee14670f0e02195c58874b846471fc4

Contents?: true

Size: 535 Bytes

Versions: 15

Compression:

Stored size: 535 Bytes

Contents

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 tag_name
        nil
      end

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

  end
end

Version data entries

15 entries across 15 versions & 4 rubygems

Version Path
andrewroth_activeadmin-0.3.4.3 lib/active_admin/arbre/html/text_node.rb
andrewroth_activeadmin-0.3.4.2 lib/active_admin/arbre/html/text_node.rb
andrewroth_activeadmin-0.3.4.1 lib/active_admin/arbre/html/text_node.rb
andrewroth_activeadmin-0.3.4 lib/active_admin/arbre/html/text_node.rb
activeadmin-0.3.4 lib/active_admin/arbre/html/text_node.rb
activeadmin-0.3.3 lib/active_admin/arbre/html/text_node.rb
activeadmin-0.3.2 lib/active_admin/arbre/html/text_node.rb
activeadmin-0.3.1 lib/active_admin/arbre/html/text_node.rb
activeadmin-0.3.0 lib/active_admin/arbre/html/text_node.rb
nsm-activeadmin-0.2.2 lib/active_admin/arbre/text_node.rb
saulolso-activeadmin-0.2.2.1 lib/active_admin/arbre/text_node.rb
saulolso-activeadmin-0.2.2 lib/active_admin/arbre/text_node.rb
activeadmin-0.2.2 lib/active_admin/arbre/text_node.rb
activeadmin-0.2.1 lib/active_admin/arbre/text_node.rb
activeadmin-0.2.0 lib/active_admin/arbre/text_node.rb