Christoph Reck :
> I've been thinking of the backslash problem using it as escape
> character. I believe the standard approach taken is in the wrong
> direction, thus causing lateral problems (see gunnar's message
> below).
You both are 100% right, and it's my bug that has us discussing this. I
should have thought it through. :)
To me, the idea behind all of this :
1) that we need to only 'escape' when we want to show the literal
representation of a valid reference and/or directive in the VTL proper.
This is fondly known as 'showing your underwear'. :)
2) Otherwise, we want it to be clear for designers and other content
producers that \ is a \ and only a \
> The simpler solution is to use special context identifiers
> to represent the $ and # symbols. To emit an '$foo' and
> #if' text in schmoo use '$$foo' and '$#if' in the template,
> thus not having to embed another syntax (escape cahracter)
> and keeping in line with the special VTL symbols!
I have a counter proposal that I feel gets us what we want, while :
- preserving the intuition of programmers to escape with \
- preserving the intuition of designers and content people that \ is a \.
- keeping the number of magic characters / sequences for the parser to a
minimum :
$ implies reference
# implies directive
And I note that :
- we already have the notion of 'modifier' in the '!' character which
'quiets' references as in $!foo
so :
Propose: simply to move the \ into the ref or macro as a 'modifier' just
like ! for references
$\<reference> outputs $<reference> if a valid reference, $\<reference>
otherwise
#\<directive> outputs #<directive> if a valid directive, #\<directive>
other
just like :
$!<reference> outputs $<reference> if a valid reference, nothing
otherwise
Beautiful symmetry (to me anyway :)
Working through the possiblities :
- if you want to output \<refvalue> just use \$<reference>.
- to output $foo when $foo is a reference, $\foo
- to output $foo when $foo isn't a reference (therefore schmoo), $foo does
it.
- to output \$foo when $foo isn't a reference (there's that shmoo again...),
\$foo does it
- to output $$foo when $foo is a ref : $$\foo
- am I missing anything?
> The generalization of this would be using ${(#|$)any text and characters}
> to be passed literally.
> Any votes in favour of this change?
> Any objections?
I kinda object because to me, I feel it complicates the VTL syntax. Since
we already have the notion of modifier in !.
It has been noted that this isn't necessarily intuitive, and I agree, but I
believe that my own intuition comes from being a programmer (or at least
playing one on TV), I believe that isn't necessarily the case for content
people and designers that would use the VTL.
Isn't this a special-case use, for either writing Vel documentation or
debugging? Maybe I have the wrong idea about this... Hm.
geir