Amrita parse error

Hello,
I’m building a web site with ruby/mod_fastcgi/postgres that uses amrita
for it’s presentation layer. I’m having a problem parsing XHTML files.
Specifically, when I try to add the XHTML namespace declaration:

I get the following amrita error:


/usr/local/lib/ruby/site_ruby/1.8/amrita/template.rb:402:in expand' /usr/local/lib/ruby/site_ruby/1.8/amrita/template.rb:138:inexpand’
/usr/local/lib/ruby/site_ruby/1.8/amrita/template.rb:144:in setup' /usr/local/lib/ruby/site_ruby/1.8/amrita/template.rb:179:insetup_template’
/usr/local/lib/ruby/site_ruby/1.8/amrita/template.rb:396:in load_template' /usr/local/lib/ruby/site_ruby/1.8/amrita/parser.rb:279:inparse_file’
/usr/local/lib/ruby/site_ruby/1.8/amrita/parser.rb:279:in open' /usr/local/lib/ruby/site_ruby/1.8/amrita/parser.rb:280:inparse_file’
/usr/local/lib/ruby/site_ruby/1.8/amrita/parser.rb:275:in parse_io' /usr/local/lib/ruby/site_ruby/1.8/amrita/parser.rb:301:inparse’
error hapend in /var/www/pennytracker/templates/signup.html:0(can’t happen)
==>:lang=“en” lang=“en”>

I’m trying to follow some of the best practices recommended in Zeldman’s
DESIGNING WITH WEB STANDARDS, which by the way is a must-read for any
aspiring web developer. He says this declaration is important. Whether
it is important or not, it’s sad that amrita doesn’t know how to parse
XHTML.

The whole approach of parsing HTML seems like overkill to me. I haven’t
found a better template option than amrita so far, but it seems like the
better solution would be to embed template instructions in HTML comments
and ignore everything else.

Any ideas about how to fix this parse error?

Thanks,
Carl

From: Carl Youngblood [mailto:carl@ycs.biz]

Amrita uses html-parser by default, which I believe doesn’t handle
namespaces at all.

The easiest possible workaround is to run with REXML as the parser. Just set
TemplateText#xml => true.

Sample is below:
require “amrita/template”
include Amrita

tmpl_text = <<-END

<?xml version="1.0"?> xhtml sample END

data = {}

tmpl = TemplateText.new tmpl_text
tmpl.prettyprint = true
tmpl.xml = true # use REXML parser
tmpl.asxml = true
tmpl.expand(STDOUT, data)

I was disatisfied with amrita’s speed, so I have written a simpler XML
template system using ruby-xmlparser (expat) which acts like a very stripped
down version of amrita. It works, but I just wrote it very recently for my own
website and haven’t had too much time to thoroughly test it. It also isn’t
documented at all.

If you are interested, grab the file at

http://www.rufuran.org/kodama.tar.gz

Since it’s not documented and has somewhat different usage than amrita, please
email me if you can’t figure out how to use it.

···


Lo-lee-ta: the tip of the tongue taking a trip of three
steps down the palate to tap, at three, on the teeth.
Lo. Lee. Ta. GUO Shu-yu shu@rufuran.org