You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Serge Knystautas <se...@lokitech.com> on 2002/11/04 00:00:23 UTC

Default to quiet references

I'm sorry if this is documented somewhere, but I spent a while reading over
the docs and mailing list archives and couldn't find this.

Normally if $foo appears in a template and foo doesn't exist, then it gets
printed as $foo.  Alternatively you could have your template use $!foo, so
it will display remove the reference.  For the system we're using, users
will pretty much never want $foo to be displayed, and the number of possible
null values is relatively high.  What I'd like to do is have a configuration
setting have $foo act like $!foo, so $foo never gets printed in the output.

Are other people interested in this and/or give me any pointers as to where
in the code I should look to make this kind of change?

Serge Knystautas
Loki Technologies - Unstoppable Websites
http://www.lokitech.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Default to quiet references

Posted by Andy Lee <ag...@earthlink.net>.
At 8:00 AM -0500 11/4/02, Serge Knystautas wrote:
>Thanks for the suggestion, but I'm really just trying to keep it 
>easy for the users.  I think $!foo would be easier than #qu( $foo ), 
>so assuming it's not possible now, I'll go hack something myself and 
>submit a patch if desired.
>

Sure, that makes sense.  Back to an earlier question, then:

At 6:00 PM -0500 11/3/02, Serge Knystautas wrote:
>What I'd like to do is have a configuration setting have $foo act 
>like $!foo, so $foo never gets printed in the output.
>
>Are other people interested in this and/or give me any pointers as 
>to where in the code I should look to make this kind of change?

I would like to have such a setting, perhaps in velocity.properties. 
Or maybe what I really want is the opposite -- a setting that forces 
all references to be non-quiet?  Or maybe I want both options?  Brain 
overload... I haven't thought it through.

All I know is, the behavior of normal references is almost never what 
I really want.  To me, the benefit of the default behavior is that it 
forces me to debug my templates and be conscious of what the 
reference evaluates to.  Otherwise I could just make all my 
references quiet, right?  But once I've done my debugging, I usually 
want nulls to be ignored.

--Andy

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Default to quiet references

Posted by Serge Knystautas <se...@lokitech.com>.
Andy Lee wrote:
> I know you're asking about adding a configuration option to the 
> language, but have you considered using a macro?  Something like:
> 
> $foo          ## never quiet
> $!foo         ## always quiet
> #qu( $foo )   ## quiet iff $forceQuiet is true
> #qu( $!foo )  ## doesn't make sense to use

Thanks for the suggestion, but I'm really just trying to keep it easy 
for the users.  I think $!foo would be easier than #qu( $foo ), so 
assuming it's not possible now, I'll go hack something myself and submit 
a patch if desired.

-- 
Serge Knystautas
Loki Technologies - Unstoppable Websites
http://www.lokitech.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Default to quiet references

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On 11/4/02 12:15 AM, "bob mcwhirter" <bo...@werken.com> wrote:

>> BTW, I find it amusing that "quiet" references are indicated by the
>> "bang" character.  I suspect the language designers found it amusing
>> too.
> 
> Yah, that's a carry-over from my iSpock template engine.
> 
> I can't remember why I picked '!' exactly, but it probably had something
> to do with visual clarity and ease of lexing.
> 

If I remember right, we had a long debate about this one.  We should go see
the archives to see whatelse was proposed...

-- 
Geir Magnusson Jr. 
geirm@adeptra.com                                    +1-203-355-2219 (w)
Adeptra Inc.                                         +1-203-247-1713 (m)



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Default to quiet references

Posted by bob mcwhirter <bo...@werken.com>.
> BTW, I find it amusing that "quiet" references are indicated by the 
> "bang" character.  I suspect the language designers found it amusing 
> too.

Yah, that's a carry-over from my iSpock template engine.

I can't remember why I picked '!' exactly, but it probably had something
to do with visual clarity and ease of lexing. 

	-bob


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Default to quiet references

Posted by Andy Lee <ag...@earthlink.net>.
At 6:00 PM -0500 11/3/02, Serge Knystautas wrote:
>What I'd like to do is have a configuration setting have $foo act 
>like $!foo, so $foo never gets printed in the output.
>
>Are other people interested in this and/or give me any pointers as 
>to where in the code I should look to make this kind of change?

I know you're asking about adding a configuration option to the 
language, but have you considered using a macro?  Something like:


$set( $forceQuiet = false )

#macro( qu $foo )
#if( $forceQuiet )$!foo#else$foo#end
#end


On the one hand, this is cumbersome if you have a lot of $foo's in 
your code.  On the other hand, you can mix quiet references with 
conditionally quiet references, if for some reason you want to. 
(Don't ask me why, I'm just saying "if.")  You could do:


$foo          ## never quiet
$!foo         ## always quiet
#qu( $foo )   ## quiet iff $forceQuiet is true
#qu( $!foo )  ## doesn't make sense to use


BTW, I find it amusing that "quiet" references are indicated by the 
"bang" character.  I suspect the language designers found it amusing 
too.

--Andy

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>