Amrita-nuby question: generate "id="

Hi,
i’m using Amrita to generate static website pages, and having fun with
it! Now I’d like to have a navigationlist, a list where the items are
urls; all fine, but I’d like to designate one particular list-item as
"active", which is defined as id selector in the css-stylesheet for
the pages.

So the generated html-code should look something like this:

However, I cannot find a way to have Amrita generate the value
"active" for the id attribute in a list-item. I did manage, as a
side-test, to use a css class instead of an id selector, and had it
generated by Amrita, but cannot get it working with the id-selector.
In my template, I set amrita_id to ‘amrita_id’.

So my question is, how to generate a ‘<<some_tag> id="<some_value>"
…>’ with Amrita?

thxia,
Harry

Since the “id” attribute has a special meaning for Amrita itself, you
have to use a workaround. If you need to define id attributes (that is,
id attributes that are to be present in Amrita’s output), you can
insert an “id” attribute. During Amrita’s processing, all “id
attributes are renamed to “id” attributes. Something like this should
do the trick:

tmpl = TemplateText.new <<END

END

data = {:links => [“item 1”,
a(:id => “active”){“item 2 (active)”},
“item 3”]}

···

Hi,
i’m using Amrita to generate static website pages, and having fun with
it! Now I’d like to have a navigationlist, a list where the items are
urls; all fine, but I’d like to designate one particular list-item as
“active”, which is defined as id selector in the css-stylesheet for
the pages.

So the generated html-code should look something like this:

However, I cannot find a way to have Amrita generate the value
“active” for the id attribute in a list-item. I did manage, as a
side-test, to use a css class instead of an id selector, and had it
generated by Amrita, but cannot get it working with the id-selector.
In my template, I set amrita_id to ‘amrita_id’.

So my question is, how to generate a ‘<<some_tag> id=“<some_value>”
…>’ with Amrita?

thxia,
Harry

you need to pass an array of procs, one for each link, so you have the
opportunity to edit the

  • manually:

    ~/eg/ruby > cat a.rb
    require ‘amrita’
    include Amrita

    template = TemplateText.new <<-html


    html

    links =
    e(:a, :href => ‘home.html’){‘home’},
    e(:a, :href => ‘photos.html’){‘photos’},
    e(:a, :href => ‘info.html’){‘info’}

    active = links[1]

    data = {
    :list => links.map do |link|
    lambda do |li|
    li[:id] = ‘active’ if link == active
    li.init_body { link }
    li
    end
    end
    }

    template.prettyprint = true
    template.expand STDOUT, data

    ~/eg/ruby > ruby a.rb

    -a

    ···

    On 26 Jan 2004, Harry wrote:

    Date: 26 Jan 2004 09:33:48 -0800
    From: Harry hvs1@chello.nl
    Newsgroups: comp.lang.ruby
    Subject: amrita-nuby question: generate “id=”

    Hi,
    i’m using Amrita to generate static website pages, and having fun with
    it! Now I’d like to have a navigationlist, a list where the items are
    urls; all fine, but I’d like to designate one particular list-item as
    “active”, which is defined as id selector in the css-stylesheet for
    the pages.

    So the generated html-code should look something like this:

    However, I cannot find a way to have Amrita generate the value
    “active” for the id attribute in a list-item. I did manage, as a
    side-test, to use a css class instead of an id selector, and had it
    generated by Amrita, but cannot get it working with the id-selector.
    In my template, I set amrita_id to ‘amrita_id’.

    So my question is, how to generate a ‘<<some_tag> id=“<some_value>”
    …>’ with Amrita?

    thxia,
    Harry

    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 :: Solar-Terrestrial Physics Data | NCEI
    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’
    ===============================================================================