logo       

Re: Custom Directive Delimiter: msg#00045

python.cheetah

Subject: Re: Custom Directive Delimiter

Alex J. Champandard wrote:
I'm trying code generation with Cheetah. I have to say it's a pleasure compared to XSLT! ;)

Yes, it most certainly is!

One thing that would help is replacing the default '#' directive tag. It'd save me the worry of escaping all my C++ \#include if I could set Cheetah to @include instead.
You mention it can be customized.
...
How is this done? I can't find much on the subject in the documentation.

It's in section 11.2 of the manual, "#compiler-settings". What you want is "directiveStartToken". You can use it in a template like so:

#compiler-settings
directiveStartToken = @
#end compiler-settings

@def foo
some stuff
@end def

Or better yet, you can add a compilerSettings argument when instantiating a Template object, like so:

t = Template(text, compilerSettings={'directiveStartToken' : '@'})

Enjoy!


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise