velocity-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Byron Foster (JIRA)" <...@velocity.apache.org>
Subject [jira] Commented: (VELOCITY-619) New set modifier so that set only assigns a value when variable is not defined.
Date Thu, 02 Oct 2008 11:11:44 GMT

    [ https://issues.apache.org/jira/browse/VELOCITY-619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12636331#action_12636331
] 

Byron Foster commented on VELOCITY-619:
---------------------------------------

Nathan,  The reason I comment that "It makes no sense" is that in my interpretation the bang
 modifier instructs the set directive to only assign a value if the variable is undefined.
 So In the situation:

 #set($!foo.bar = 2) 

If we are NOT in strict mode, and 'bar' does not exist, then this statement will be ignored.
If we are in strict mode, and 'bar' does not exist, then an exception will be thrown.

Ultimately, In the above case, the bang modifier will never change the behavior of the set
directive,  but maybe throwing an exception is to draconian, and just letting it go is the
better option.



> New set modifier so that set only assigns a value when variable is not defined.
> -------------------------------------------------------------------------------
>
>                 Key: VELOCITY-619
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-619
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>            Reporter: Byron Foster
>         Attachments: setBangModifier_2.patch
>
>
> Define a new #set modifier such that a variable is only set if it is not defined, like
so:
> #set($!foo = "bar")
> If the '!' character proceeds the variable foo, then $foo will be set with the value
of "bar" ONLY IF $foo is not defined (is not in the context).  Otherwise if $foo is defined
it will remain unchanged.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


Mime
View raw message