Any Amrita experts out there…
I have a tag which contains another tag. I want to set the body text of the
parent tag and set an attribute of the child tag, and I can’t for the life
of me figure out how to do it.
Here’s the example:
— 8< -------------------------------------------------------------
require 'amrita/template’
include Amrita
template = Amrita::TemplateText.new(<<EOS)
What I want to do is:
(1) replace 'REPLACE ME ’ with some text
(2) Conditionally keep the hyperlink, and set its href attribute
Desired output:
Foo thing (Add)
bar
Foo thing (Add)
bar
‘add’ is a child of ‘item’, but how do I set 'item’s body text whilst at
the same time setting the child attribute?
template.expand($stdout, { :items=>[
{ :item=>{
:body=>‘Foo thing’, # <<<<< Not like this, but how?
:add=>a(:href=>“wibble.cgi?add=foo”)
} },
{ :item=>‘bar’ }, # no :add, this item doesn’t need the tag
]})
This version sets the text, but removes the (Add) tag
template.expand($stdout, { :items=>[
{ :item=>proc { |e|
e.set_text(‘Foo thing’)
e
} },
{ :item=>‘bar’ },
]})
— 8< -------------------------------------------------------------
I guess I could change my template to
in which case it’s straightforward, but I just wondered if I was missing
a way of doing this directly?
Cheers…
Brian.