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 12:24:25 GMT
"Geir Magnusson Jr." wrote:
>
> On 3/13/02 5:19 AM, "Christoph Reck" <Christoph.Reck@dlr.de> wrote:
>[snip]
> >
> > Obvious (vs. defined) whitespace handling will make velocity a winner.
> 
> Lets be frank - the handling is defined.  There is no stochastic aspect to
> whitespace handling.  The question is how it is defined.

With "Obvious" I meant "what designers expect", which is that directives
are transparent to the output (including surrounding spaces when the
directives are standing alone, each on its own line).

>[snip]
> [SNIP]
> >> 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(...)##...
> 
> And this is an improvement over the XSLT approach?

IMHO, yes. 
I'm proposing a very simple contract from whitespace handling/gobbling:
  standalone -> gobble whitespace
  embedded -> passtrough whitespace

> 
> > 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).
> 
> No way :)

No way what? Adding a macro to document that spaces are to be kept?
             Voting for the whitespace handling proposal?
             Does the current contract keep whitespace prefixes but gobbles
               them up to and including the newline?

> 
> 
> > BTW. how does a template designer edit a character stream source, or does
> > the source of the stream insert the directives and references?
> 
> They can be mechanically generated...
> 
> > 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...
> 
> To me, a 'funny' aspect of this discussion is that we (Velocity users) seem
> to mostly use Velocity to generate HTML, which is almost totally immune to
> the issue of whitespace making output look dodgy....

1rst: There a purists that want to publish pretty formatted HTML
2nd:  This thread and others in the cocoon list show that template 
      transformation is also used for other purposes where the generated
      output is looked at by people.
3rd:  There are cases in HTML where whitespaces do matter, e.g. spaces
      in between images, or besides images within tables...

> 
> geir
> 

Tanks for taking time to think it through. Hopefully with a good 
conclusion - as we have not been dissapointed by your great ideas 
in the past!

-- 
:) 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