I finally managed to create my first internal DRYML extension :)

<abc/>
---
<def tag="abe" join="X">
  <me/>
  <you/>
</def>
---
Renders:
me X you


template.rb:
---------------

line 103-145:
   def element_after(nodes, index)
      next_index = index+1
      nodes_after = nodes.children[next_index..nodes.size]
      # logger.debug("CLASS: #{nodes.class} #{next_index} of #
{nodes.size} #{nodes.children.size} #{nodes.children.class}")
      # logger.debug nodes.to_yaml if rand(60) == 1
      nodes_after.each_with_index do |node, index|
        found = false
        case node
          when REXML::Element
            found = true
            logger.debug("FOUND #{index}")
        end
        return true if found
      end
      false
    end


    def children_to_erb(nodes, options = nil)
      # nodes.map { |x| node_to_erb(x) }.join
      res = ""
      join_str = options && options[:join]  || ""
      if join_str != ""
        nodes.each_with_index do |node, index|
          r = node_to_erb(node)
          case node
            when REXML::Element
              elem_after = element_after(nodes, index)
              logger.debug(elem_after)
              if elem_after
                res << (r + join_str)
              else
                res << r
              end
            else
              res << r
          end
        end
        res
      else
        nodes.map { |x| node_to_erb(x) }.join
      end
    end


line 348:
      options = {:join => join_str}

      res = if alias_of
              "<% #{tag_newlines(el)} %>"
            else
              src = tag_method(name, el, extend_tag, options) +

line 379:
    def tag_method(name, el, extend_tag=false, options = nil)

line 392:
        tag_method_body(el, options) +

line 399:
    def tag_method_body(el, options = nil)

line 412:
        wrap_tag_method_body_with_metadata(children_to_erb(el,
options)) +


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to