On Wed, 24 Dec 2003, Carl Youngblood wrote:

> Date: Wed, 24 Dec 2003 05:17:38 GMT
> From: Carl Youngblood <carl / ycs.biz>
> Newsgroups: comp.lang.ruby
> Subject: amrita question
> 
> I'm having a weird problem with amrita.  I need to have the contents of 
> a tag attribute be dynamically generated.  So, if my template file has:
> 
> <form method="post" action="<DYNAMIC CONTENT NEEDS TO BE PLACED HERE>">
> 	...
> </form>
<snip>

amrita is very smart, if you do not specify new content it does not delete
what's already there.  combine that with the ability to replace attributes and
you can do exactly what you want:

  ~ > cat /tmp/foo.rb 
  require 'amrita/template'
  include Amrita

  t = TemplateText.new <<-html
    <form method=post action=DYNAMIC_CONTENT_NEEDS_TO_BE_PLACED_HERE id=form>
      <input type=text name=foobar>
    </form>
  html

  t.expand STDOUT, :form => a(:action => 'myform.cgi')


  ~ > ruby  /tmp/foo.rb
    <form method="post" action="myform.cgi">
      <input type="text" name="foobar">
    </form>

cheers.

-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' 
===============================================================================