You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Christoph Reck <Ch...@dlr.de> on 2001/05/02 14:26:21 UTC

Re: WM difference question

Wow this thread has been amusing. Cheers to all of you being polite
in the exchange (I remember other tones at some time...).

I also prefer the {} to differentiate it from math equation grouping
and from java casts. I do believe there could be some other choices
(not [] since this is frequently used for indexes) like $foo;bar
or even the no-effort form of $foo#**#bar, which I use to separate 
#if($foo)bar#else#**#woobie#end sucessfully.

some more below...

"Geir Magnusson Jr." wrote:
> 
> Chuck Esterbrook wrote:
> >
> > At 09:26 AM 4/30/2001 -0700, Jon Stevens wrote:
> > >on 4/30/01 6:26 AM, "Geir Magnusson Jr." <ge...@optonline.net> wrote:
> > >
> > > > I suppose that it's modeled after shell scripting, where you can use {}
> > > > to contrain a variable token.
> > > >
> > > > geir
> > >
> > >That is why I like it better than parens.
> >
> > I prefer ()s myself. I think they are a bit more normal, and my biggest
> > template users don't know anything about shell scripts; just HTML.
> 
> Then I guess they would like to see pointy things '<' and '>'
>[snip]
> > By the way, folks in "my camp" are creating a Velocity-inspired templating
> > package in Python. Hence my interest in design choices.
> 
> I guess you'd use whitespace to delimit things in a python inspired
> template engine?

Then you are free to do your own choices... But I (we all) think VTL
is a KISS language and it would be great if other implementations
would follow it.

I've implemented PQL in the past (1997) using perl (replacing a C language
implementation). It loaded its context from a [grouped]key=value
file (*.INI style) which was then ammeded via code (like Vel setting up
the context). The syntax looked like
  [key]               referencing the value of key using the default group
  [group:key]         referencing the value of key within a specific group
  [group:key=foo]     is the set function
  [group:key?foo|bar] is the java-inline-if counterpart
  [group:*[this]]     replaces this with each entry of the group (==foreach)
  [group:key==a string?foo|bar] 
                      more complex ifs (also allowed .eq., .le., etc. operators)
  [<filename]         includes a file
  [#...]              a comment
  [[foo]==[bar]?[Nesting is allowed]]
And this was a great, simple and compact template language. 

Velocity is just as great and simple - and more powerful with its
introspection... I would like it to be more whitespace concient: directives
standalone in a line should not emit any leading whitespaces (trailing 
whitespace is already gobbled).

:) Christoph

Re: WM difference question

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
David Rees wrote:
> 
> :-)  You are correct.  However, there are cases when it'd be useful to turn
> off whitespace, but I haven't thought of a good, clean way to do it.  I
> don't know if there is, so it's better to just have to deal with the
> whitespace in the normal manner.

I was thinking about this when wandering down my driveway to get the
paper this morning and have a few ideas, so will try to find some
freetime and play with them.

The issues that come up are 'accuracy' vs 'what you expect', as people
doing HTML don't care most of the time about extra whitespace, where a
person formatting a report would,  and 'pretty templates' vs 'pretty
output' -> for example, when using Vel to generate code (Java, SQL,
etc), what do you want to be pretty?  The template for you author, or
the generated code, the output.  I think it depends on the specific
context, as some people don't look at the generated code (but some do),
and you can see how this contrasts with HTML output, which is tolerant
of pretty much anything.

However, we already aren't pure : #<directive>() should automatically
eat the newline right now :)

geir

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/

RE: WM difference question

Posted by David Rees <dr...@ebetinc.com>.
> From: gmj@mta6.srv.hcvlny.cv.net [mailto:gmj@mta6.srv.hcvlny.cv.net]On
> Behalf Of Geir Magnusson Jr.
>
> Technically speaking :)  there's going to be a newline after 'bar', as
> you have that in the block.  The #else is the block boundary - there
> would be no way otherwise do add a newline -
>
> for example
>
> ---
> #foreach( $i in [1..3])
> $i
> #end
> ---
>
> produces
>
> ---
> 1
> 2
> 3
> ---
>
> versus
>
> ---
> #foreach( $i in [1..3] )
> $i#end
> ---
>
> produces
>
> ---
> 123---

:-)  You are correct.  However, there are cases when it'd be useful to turn
off whitespace, but I haven't thought of a good, clean way to do it.  I
don't know if there is, so it's better to just have to deal with the
whitespace in the normal manner.

-Dave


Re: WM difference question

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
David Rees wrote:
> 
> > From: Christoph.Reck@esrin.esa.it
> >
> <snip>
> >
> > Velocity is just as great and simple - and more powerful with its
> > introspection... I would like it to be more whitespace concient:
> > directives
> > standalone in a line should not emit any leading whitespaces (trailing
> > whitespace is already gobbled).
> 
> I would like to see this.  This lets us expand things like (stealing from
> Christoph's example):
> 
> #if($foo)bar#else#**#woobie#end
> 
> into this:
> 
> #if($foo)
> bar
> #else
> #woobie
> #end
> 
> Which IMO makes things more readable.
> 

Technically speaking :)  there's going to be a newline after 'bar', as
you have that in the block.  The #else is the block boundary - there
would be no way otherwise do add a newline - 

for example

---
#foreach( $i in [1..3])
$i
#end
---

produces

---
1
2
3
---

versus

---
#foreach( $i in [1..3] )
$i#end
---

produces

---
123---


geir

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting

Developing for the web?  See http://jakarta.apache.org/velocity/

RE: WM difference question

Posted by David Rees <dr...@ebetinc.com>.
> From: Christoph.Reck@esrin.esa.it
>
<snip>
>
> Velocity is just as great and simple - and more powerful with its
> introspection... I would like it to be more whitespace concient:
> directives
> standalone in a line should not emit any leading whitespaces (trailing
> whitespace is already gobbled).

I would like to see this.  This lets us expand things like (stealing from
Christoph's example):

#if($foo)bar#else#**#woobie#end

into this:

#if($foo)
bar
#else
#woobie
#end

Which IMO makes things more readable.

-Dave