I am trying to find a nice template solution in Ruby, and amrita looks kind
of good, but I’m also worried that it is moving further in a direction that
is against my interests. I noticed, for example, that in the latest
RELEASENOTE, under MergeTemplate, it says “not supported. use Amulet
instead.” And yet the amulet examples that it does show don’t seem to
accomplish quite the same things as merging two templates together. (It
would help if there actually was documentation for amulet, but that is
another story).
The problem, as I see it, is that the new examples that are shown have a
strong coupling between ruby code and templates. In the parts template, for
example, you are actually creating ruby classes for different HTML elements.
i can easily see (share) that point of view.
What I really want is to have template files that don’t have an ounce of
ruby code inside of them, that I can give to a blockhead graphic designer
and just tell him that they are HTML snippets and that he can change them
all he wants as long as he doesn’t get rid of the amrita ids.
AND their nesting since:
!=
not that it’s too tough a requirement… i’ve been doing my stuff the same
way. i provide a means to dynamically link in style sheets, make basic
templates and say “don’t like, fix it!”. saves me from changing the bloody
colour of tables cells, etc.
The templates have to be nestable, however, because I don’t want to have to
duplicate code from one page to the next.
what’s wrong with sanitzing your nested templates? or using noescape with
appropriate amrita version? as far as i can tell that’s what it’s there for:
filling in html with html. i hate security anyway. 
So, I really appreciate your time, but the first example, which is
acceptable to my usage model, I couldn’t get working, and the other
example(s) really aren’t going to work with the way I want to develop my
site. Any other ideas?
how about:
~/eg/ruby > cat amrita0.rb
require ‘amrita’
include Amrita
inner template
it = TemplateText.new <<-html
List of messages
html
outer template
ot = TemplateText.new <<-html
html
build msglist
data = Hash.new{|h,k| h[k] = }
messages = %w(one two three)
messages.inject(data){|data, msg| data[:list] << {:msg => msg}; data}
msglist = it.expand(‘’, data)
build main page
data = Hash.new
data[:msglist] = SanitizedString[msglist]
ot.expand(STDOUT, data)
~/eg/ruby > ruby !$
List of messages
i thinks using SanitizedString for these cases (re-using bits and peices) is
perfectly valid since you, the programmer has complete control over what and
where they go. the only possible problem would be filling in these bits from
dynamic user input - even then you can be sure to CGI::escape the user input
to remove and potential XSS attacks. easy cheesey.
the point is this:
iff you are going to expand html in html there is always the possibility of
inserting something malicious or simply incorrect. amrita protects against
this by default, but gives you the means to turn it off - i can only assume
that this ability was provided for your exact usage.
having said that, have you checked out misen? i like it, but it does break
html (though not very badly). it’s ‘aquisitive’ feature is really cool. for
the moment however i’m sticking with amrita because it does not break html and
seems to be under active development.
please let me know what solution you end up going with since i’m quite
interested in the best approach to this problem as well.
regards.
-a
···
On Fri, 19 Dec 2003, Carl Youngblood wrote:
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’
===============================================================================