Loss of newline when using directiveStartToken and commentStartToken

Jonathan Giddy <[email protected]> Mon, 03 Aug 2009 13:47:43 +0100
Newsgroups gmane.comp.python.cheetah
Message-ID <[email protected]>
Hi, I am a user of Bcfg2, using their support for Cheetah templating. In 
this context, I am using Cheetah within Unix shell-style files, where # 
is the comment marker. As such I attempt to "rename" the Cheetah 
directive and comment markers.

I am finding that whitespace goes missing after "blank" comment lines. 
Instead of being passed through as literals, the text "# \n" becomes "", 
and "## \n" becomes "#". Any spaces before the newline are also 
swallowed up.

I was originally using Cheetah 2.0.1 on CentOS 5.3, but this problem 
occurs in 2.2.1 on Ubuntu 8.04 as well. As an example, my template is:
## '#' and '##' have special meaning to Cheetah, rename them to '@' and '@@'
#compiler-settings
directiveStartToken = @
directiveEndToken = @
commentStartToken = @@
#end compiler-settings
@@ Actual file starts on next line
## Here is a comment followed by a blank comment line
##
echo 1
## The echo command should not be commented out
##
## Do I have 2 or 3 # marks?
#
# Can you see a blank comment line above?

Running "cheetah compile template" gives a template whose output is:
## Here is a comment followed by a blank comment line
#echo 1
## The echo command should not be commented out
### Do I have 2 or 3 # marks?
# Can you see a blank comment line above?



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july