Amrita question(s)

M

Michael Campbell

First off, is this the place to ask? If not, apologies, and please
point me to the right spot.

2 questions:

1 Is "span" the recommended way of dumping an element outside of any
other tags, when no formatting is required (nor desired)?

2 Is there a way to mask out non-data elements if a data-element
doesn't exist?

Suppose I have in my html:

Name: <span id=name></span>

I don't want "Name:" to show if the :name id doesn't exist. I'm sure
I'm overlooking something fundamental here, but I've just started so
not sure where to look.

Thanks,

Michael

__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/
 
A

Ara.T.Howard

First off, is this the place to ask? If not, apologies, and please point me
to the right spot.

i'll let someone else answer that. IMHO ruby has big potential to be a
leading web development tool and being a leading web development tool means
being a leading development tool so discussion on how to get there are on
topic.
2 questions:

1 Is "span" the recommended way of dumping an element outside of any
other tags, when no formatting is required (nor desired)?

yes. also there is <div/>, but IE does funny things with it. i generally use
div. note that when a span has no attributes _other_ that 'id' the tag is not
actually included in the output: it's simply a way to include data without
breaking the html files:

~/eg/ruby > cat a.rb
require 'amrita/template'; include Amrita
t = TemplateText.new '<span id=foo></span>'
t.expand STDOUT, :foo => 42

~/eg/ruby > ruby a.rb
42
2 Is there a way to mask out non-data elements if a data-element doesn't
exist?

Suppose I have in my html:

Name: <span id=name></span>

I don't want "Name:" to show if the :name id doesn't exist. I'm sure
I'm overlooking something fundamental here, but I've just started so
not sure where to look.

simply do not put ':name' into you data structure:

~/eg/ruby > cat b.rb
require 'amrita/template'; include Amrita
t = TemplateText.new '<span id=foo></span><span id=name>not included</span>'
t.expand STDOUT, :foo => 42

~/eg/ruby > ruby b.rb
42

you can use this approach to block out huge portions of html conditionally.

-a
--

ATTN: please update your address books with address below!

===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| STP :: http://www.ngdc.noaa.gov/stp/
| NGDC :: http://www.ngdc.noaa.gov/
| NESDIS :: http://www.nesdis.noaa.gov/
| NOAA :: http://www.noaa.gov/
| US DOC :: http://www.commerce.gov/
|
| The difference between art and science is that science is what we
| understand well enough to explain to a computer.
| Art is everything else.
| -- Donald Knuth, "Discover"
|
| /bin/sh -c 'for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done'
===============================================================================
 
C

Carl Youngblood

I checked out the amrita mailing list and the archives seem to indicate
that it is defunct. So I think that this is the next most closely
related list for stuff like this. At least, this has been my assumption.

I think the answer to #1 is yes. If you just want text of some kind and
no other formatting, or if formatting has been declared elsewhere
already, then span is what you want to use.

The answer to #2, is that this is what amrita does by default. If you
want to keep the unfound tags in, you have to set template.keep_id to
true ("template" here is an instance of TemplateFile).

However, your example is showing something slightly different. I would
do something like:

<span id=name></span>

in my template file and then just

data[:name] = 'Name: Joe Blow'

That way you get all or nothing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top