poroblem with linefeed in velocity templates

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

poroblem with linefeed in velocity templates

Bartsch.Mike
Hello,
 
i'll use velocity to generate some textfiles, so i wrote a script like
this:
 
textfield_one:    $ref_variable_one
textfield_two:    $ref_variable_two
 
textfield_three:  $ref_variable_three
textfield_four:    $ref_variable_four
 
it was rendered to:
 
textfield_one:    one
textfield_two:    two
 
textfield_three:  three
textfield_four:    four
 
everything is fine!
 
But now after changes to
 
textfield_one:    #if($ref_variable_one != "") $ref_variable_one #end
textfield_two:    #if($ref_variable_two != "") $ref_variable_two #end
 
textfield_three:  #if($ref_variable_three != "") $ref_variable_three
#end
textfield_four:    #if($ref_variable_four != "") $ref_variable_four #end
 
it will be render to:
 
textfield_one:    one textfield_two:    two
textfield_three:  three textfield_four:    four
 
Did anyone know a solution for this problem?
 
Many thanks!
 
Mike Bartsch
 
 
 
Reply | Threaded
Open this post in threaded view
|

Re: poroblem with linefeed in velocity templates

Shinobu Kawai
Hi Mike,

> But now after changes to
>
> textfield_one:    #if($ref_variable_one != "") $ref_variable_one #end
> textfield_two:    #if($ref_variable_two != "") $ref_variable_two #end
>
> textfield_three:  #if($ref_variable_three != "") $ref_variable_three
> #end
> textfield_four:    #if($ref_variable_four != "") $ref_variable_four #end
>
> it will be render to:
>
> textfield_one:    one textfield_two:    two
> textfield_three:  three textfield_four:    four
>
> Did anyone know a solution for this problem?

Another case of VelocityWhitespaceGobbling.
  http://jakarta.apache.org/velocity/user-guide.html#VTL:%20Formatting%20Issues
  http://wiki.apache.org/jakarta-velocity/VelocityWhitespaceGobbling

One thing you can do, is add a line feed before the #end.

textfield_one:    #if($ref_variable_one != "") $ref_variable_one
#end
textfield_two:    #if($ref_variable_two != "") $ref_variable_two
#end

textfield_three:  #if($ref_variable_three != "") $ref_variable_three
#end
textfield_four:    #if($ref_variable_four != "") $ref_variable_four
#end

Best regards,
-- Shinobu

--
Shinobu Kawai <[hidden email]>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: poroblem with linefeed in velocity templates

apache-10
<grinn/>
this is a case where my StructuredWhitespaceGobbling proposal would
do the right_thing(tm). THis is an example where it minimally breaks BC.

;) Christoph Reck


Shinobu Kawai wrote:

> Hi Mike,
>
>
>>But now after changes to
>>
>>textfield_one:    #if($ref_variable_one != "") $ref_variable_one #end
>>textfield_two:    #if($ref_variable_two != "") $ref_variable_two #end
>>
>>textfield_three:  #if($ref_variable_three != "") $ref_variable_three
>>#end
>>textfield_four:    #if($ref_variable_four != "") $ref_variable_four #end
>>
>>it will be render to:
>>
>>textfield_one:    one textfield_two:    two
>>textfield_three:  three textfield_four:    four
>>
>>Did anyone know a solution for this problem?
>
>
> Another case of VelocityWhitespaceGobbling.
>   http://jakarta.apache.org/velocity/user-guide.html#VTL:%20Formatting%20Issues
>   http://wiki.apache.org/jakarta-velocity/VelocityWhitespaceGobbling
>
> One thing you can do, is add a line feed before the #end.
>
> textfield_one:    #if($ref_variable_one != "") $ref_variable_one
> #end
> textfield_two:    #if($ref_variable_two != "") $ref_variable_two
> #end
>
> textfield_three:  #if($ref_variable_three != "") $ref_variable_three
> #end
> textfield_four:    #if($ref_variable_four != "") $ref_variable_four
> #end
>
> Best regards,
> -- Shinobu
>
> --
> Shinobu Kawai <[hidden email]>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]