Aaron Lippold wrote:
/s/When cheetah naturally/When I don't escape the ${var} cheetah/g
... snip ...
If you have large blocks of shell in %pre and %post, rather than
escaping them in Cheetah, I just discovered you can exclose them in #raw
... #endraw blocks.
http://www.cheetahtemplate.org/docs/users_guide_html/users_guide.html#SECTION000850000000000000000
If you have template variables (--ksmeta) that you want to access from
shell, you can assign them to shell variables in your %pre or %post
sections and
then use them from inside the raw sections.
See example:
===
#!/usr/bin/python
from Cheetah.Template import *
# notice how I am setting foo and bar such that they'll be available in
the raw section...
data = """#errorCatcher Echo
\$foo = $foo
\$bar = $bar
#raw
if [ $(grep \" /home \" #echo "${FSTAB} | grep -c \"nosuid\") -eq 0 ];
then"
# use $foo
# use $bar
#endraw
"""
search = {
"foo" : "gleep",
"bar" : "gloop"
}
t = Template(source=data, searchList=[search])
print str(t)
===
This seems to me a lot cleaner than doing the escaping or needing to
understand the escaping rules.
--Michael