Sha256: 587d7cedcd8d74facf6a96597a2423c7ed493349539ac1688bb1824edb97512e

Contents?: true

Size: 1.03 KB

Versions: 16

Compression:

Stored size: 1.03 KB

Contents

require 'glimmer'
require 'glimmer/dsl/parent_expression'
require 'glimmer/xml/node'

module Glimmer
  module DSL
    module XML
      module NodeParentExpression
        include ParentExpression
        include Glimmer

        def add_content(parent, &block)
          return_value = block.call(parent)      
          if !return_value.is_a?(Glimmer::XML::Node) and !parent.children.include?(return_value)
            text = return_value.to_s
            first_match = text.match(/[#][^{]+[{][^}]+[}]/)
            match = first_match
            while (match)
              instance_eval(parent.text_command(match.pre_match))
              tag_text = match.to_s
              instance_eval(parent.rubyize(tag_text))
              text = tag_text
              post_match = match.post_match
              match = text.match(/[#]\w+[{]\w+[}]/)
            end
            instance_eval(parent.text_command(post_match)) if post_match
            parent.children << return_value unless first_match
          end
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
glimmer-dsl-xml-0.2.0 lib/glimmer/dsl/xml/node_parent_expression.rb
glimmer-dsl-xml-0.1.0 lib/glimmer/dsl/xml/node_parent_expression.rb
glimmer-dsl-css-0.1.0 lib/glimmer/dsl/xml/node_parent_expression.rb
glimmer-0.8.2 lib/glimmer/dsl/xml/node_parent_expression.rb
glimmer-0.8.1 lib/glimmer/dsl/xml/node_parent_expression.rb
glimmer-0.8.0 lib/glimmer/dsl/xml/node_parent_expression.rb
glimmer-0.7.8 lib/glimmer/dsl/xml/node_parent_expression.rb
glimmer-0.7.7 lib/glimmer/dsl/xml/node_parent_expression.rb
glimmer-0.7.6 lib/glimmer/dsl/xml/node_parent_expression.rb
glimmer-0.7.5 lib/glimmer/dsl/xml/node_parent_expression.rb
glimmer-0.7.4 lib/glimmer/dsl/xml/node_parent_expression.rb
glimmer-0.7.3 lib/glimmer/dsl/xml/node_parent_expression.rb
glimmer-0.7.2 lib/glimmer/dsl/xml/node_parent_expression.rb
glimmer-0.7.1 lib/glimmer/dsl/xml/node_parent_expression.rb
glimmer-0.7.0 lib/glimmer/dsl/xml/node_parent_expression.rb
glimmer-0.6.0 lib/glimmer/dsl/xml/node_parent_expression.rb