Module Amrita::ExpandByMember
In: lib/amrita/node_expand.rb

a module to be included user's class.

    tmpl = TemplateText.new "<p id=time><em id=year></em></p>\n\n"
    tmpl.expand(STDOUT, {:time => Time.now}) # => <p>Thu Jul 18 14:38:28 JST 2002</p>

    class Time
      include ExpandByMember
    tmpl.expand(STDOUT, {:time => Time.now}) # => <p><em>2002</em></p>

At first expand, and <em id=year>..</em> was deleted and replaced with the result of to_s methodof of the Time object.

At second, the Time object is a ExpandByMember object, so amrita consider it as a structured object like Hash. <em id=year>..</em> was expanded recursivelly with the Time object. And the year method was called.

Included modules