(copied from Nathan Stitt's original email. Thanks,
Nathan!)
t = PageTemplate.new
i = Item.new
t['item'] = i
t.output
and then in the template:
<html><body>
Item picture is:
[%var item.picURL %]
</body></html>
With the results of the picURL method substituted in
the template.
Also, while I was at it I added the abilty to output
the key from a hash if the object is a hash like so:
t = PageTemplate.new
t['hash'] = Hash[ 'foo',49 ]
t.output
and the template:
key foo in Hash = [%var hash.foo %]
Changes made were:
Copied the ValueCommand class to a new ObjectCommand
class which call split on the value passed to it to get
a object/method pair. Then when output is called it
uses the ruby send function to call the method.
Created a new objval syntax wich is matched when the
varible portion of the tag has a period with text on
both sides.
Added a test for the objval syntax in Parser.compile
Patch file