Re: Create an empty java.util.Set in VTL

2018-01-25 Thread Alex Fedotov
You can probably use a hack with classloader. Along the lines of: #set($x = "1".getClass().getClassloader().findClass("java.uti.HashSet").newInstance()) Alex On Thu, Jan 25, 2018 at 11:30 AM, Christopher Schultz < ch...@christopherschultz.net> wrote: > -BEGIN PGP SIGNED MESSAGE- >

Re: strict mode but ignore null

2017-12-07 Thread Alex Fedotov
I am guessing that you can also install a reference insert handler in your setup and handle null values there as needed. Alex On Thu, Dec 7, 2017 at 9:35 AM, Claude Brisson wrote: > I looked at the code, and, well, it looks like the strict mode is ... > rather

Re: What does Velocimacro with a Body mean?

2013-08-07 Thread Alex Fedotov
It does not work because bodyContent is an instance of the ASTNode class and not a string, so it does not have the trim method. Use something like this: #macro(my_trim)#set($str=$bodyContent)$str.trim()#end Test: before#@my_trim()-blah- #{end}after Renders: before-blah-after On Wed,

Re: Returning String without Whitespace from Velocimacros

2013-08-01 Thread Alex Fedotov
Simple way: #set($str=#default_query_url()) $str.trim() Can probably create a helper macro trim that does the same thing to the body content: #@trim() #default_query_url() #end On Thu, Aug 1, 2013 at 1:27 PM, O. Olson olson_...@yahoo.it wrote: Hi, I am new to using Apache Velocity.

Re: Macro caching and other caching

2012-07-31 Thread Alex Fedotov
? On Thu, Jul 19, 2012 at 10:26 AM, Alex Fedotov a...@kayak.com wrote: I think that Velocity has one global hash table for macros from the *.vm libraries and that is more or less static for the life time of the Velocity engine. I wish

Re: Macro caching and other caching

2012-07-19 Thread Alex Fedotov
I think that Velocity has one global hash table for macros from the *.vm libraries and that is more or less static for the life time of the Velocity engine. I wish there there was a mechanism to control the list of the *.vm files and their order of lookup for each individual merge (thread). This

Re: partial evaluation / removing directives

2012-07-13 Thread Alex Fedotov
Another option may be rewriting the AST tree after the template is parsed and replacing some nodes with text or something else. I tried that on the side as an experiment to inject some security checks and collect profiling info for macros and templates. Alex On Fri, Jul 13, 2012 at 9:50 AM,

Re: partial evaluation / removing directives

2012-07-13 Thread Alex Fedotov
Well, I did not get into the details, but the idea would be to replace the ASTIfStatement with a sequence of AST nodes that would output the #IF text followed by the result of rewriting the children, etc. followed by the #END text. I think the SimpleNode does not have a particularly friendly