Amrita substitution question

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)

REPLACE ME (Add)
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

‘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

REPLACE ME(Add)

in which case it’s straightforward, but I just wondered if I was missing
a way of doing this directly?

Cheers…

Brian.

not an ‘expert’ - but this might work :

What I want to do is:

(1) replace 'REPLACE ME ’ with some text

(2) Conditionally keep the hyperlink, and set its href attribute

----CUT----
#!/usr/local/bin/ruby
require ‘amrita/template’
include Amrita

template = Amrita::TemplateText.new <<-html




html

data0 = {
:item => {
:text => ‘Foo thing’,
:add => false,
},
}
template.expand $stdout, data0

data1 = {
:item => {
:text => ‘Foo thing’,
:add => a(:href => “wibble.cgi?add=foo”){“(Add)”},
},
}
template.expand $stdout, data1

template = Amrita::TemplateText.new <<-html






html

data = {
:items => [data0, data1]
}
template.expand $stdout, data
----CUT----

-a

···

On Tue, 1 Apr 2003, Brian Candler wrote:

Any Amrita experts out there…

Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ahoward@fsl.noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
====================================