From: "Ara.T.Howard" Date: 2004-01-27T03:54:55+09:00 Subject: Re: amrita-nuby question: generate "id=" On 26 Jan 2004, Harry wrote: > Date: 26 Jan 2004 09:33:48 -0800 > From: Harry > 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 '< id="" > ...>' 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 -- 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' ===============================================================================