velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph Reck <Christoph.R...@dlr.de>
Subject Re: indentation of templates
Date Wed, 13 Mar 2002 10:19:08 GMT
answers inline...

"Geir Magnusson Jr." wrote:
> 
> On 3/12/02 12:29 PM, "Christoph Reck" <Christoph.Reck@dlr.de> wrote:
> 
> > Sorry, but placing the #if and #else directives at the beginning of the
> > line becomes ugly with nested conditions. It also gets ugly with
> > #set directives within...
> 
> Man, I hate this subject :)

Geir, sorry for this.

Obvious (vs. defined) whitespace handling will make velocity a winner. 
Please note that XSLT lists contain many questions on this subject, 
and XSLT offers an ugly mechanism to make the handling explicit, 
aka: <xsl:text>, <xsl:srtip-space ...>, <xsl:preserve-space ...>, and 
the xml:space attribute.

> 
> I was thinking about it today, and didn't get time to re-read all of the
> archives on this, and I promise I will, but until then, here's my
> fundamental problem with this idea.  (And yes, I see the value, and yes I
> understand we are inconsistent...)
> 
> It boils down to this :  I don't see us as always dealing with "lines of
> code" but also streams of characters.  I have done a few projects where it
> was just processing a stream (that could contain newlines), and we do try to
> portray Velocity as a general template engine.
> 
> So it's not clear to me that ascribing special meaning to the character
> sequence <newline><space><space>#if( ... Is a good thing, and to me
it's a
> struggle between one group of users wanting both pretty templates producing
> pretty code, and another group that wants magic-free rendering....

To use velocity in a stream application that may contain the sequence
<newline><space+>#directive(...) will need preventive means to keep the 
whitespaces, e.g. <newline><space+>#keepSpaces()#directive(...)
or for backward compatibility: ...<newline><space+>#directive(...)##...
The #keepSpaces macro before the directive will skip the gobbling, or the
## after the directive will also skip the prefixed whitespace gobbling, 
but will gobble trailing whitespace including a newline (which is the 
current contract).

BTW. how does a template designer edit a character stream source, or does
the source of the stream insert the directives and references? Well, if it
uses directives, he will need to take some precautions so that the directives
are surely transparent to the output, also note that velocity will attack
embedded ##s, therefore it has to filter and escape these before passing
velocity:
     aaabbbccc...2223456##
       #directive(...)
         #macroCall(...)
         #write("other schmoo characters")
       #end
789dddeeefff...xxxyyyzzz!!!@@@$$$#\##%%%...

> 
> Anyway, time will open up at the end of the week I hope, and will read the
> archives to make sure I am not missing something obvious...

This is why I restarted this thread: to get others to look at the proposal
and to check if it will break their code...

> 
> --
> Geir Magnusson Jr.                                     geirm@optonline.net
> System and Software Consulting
> The bytecodes are language independent. - Sam Ruby
> 
> --
> To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>

-- 
:) Christoph Reck

--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message