velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Bubna" <nbu...@gmail.com>
Subject Re: special character # in template doesn't work.
Date Wed, 29 Oct 2008 15:56:38 GMT
#set( $H = '#' )
$H$H$H$H$H$H$H$H$H$H$H$H$H$H$H

On Tue, Oct 28, 2008 at 9:56 PM, Linda Lee <lincle2k@sbcglobal.net> wrote:
>
>  Thanks for your reply.  Is there a way to get around it (not NOT using #).  Thanks.
>
> --- On Tue, 10/28/08, bluejoe <bluejoe2008@gmail.com> wrote:
>
> From: bluejoe <bluejoe2008@gmail.com>
> Subject: Re: special character # in template doesn't work.
> To: "Velocity Users List" <user@velocity.apache.org>
> Date: Tuesday, October 28, 2008, 8:06 PM
>
> #if
> #end
> ...
>
> # is of course a special character to declare a directive
> you can refer to VTL Reference:
> http://velocity.apache.org/engine/releases/velocity-1.5/vtl-reference-guide.html
>
> ----- Original Message -----
> From: "Linda Lee" <lincle2k@sbcglobal.net>
> To: "Velocity Users List" <user@velocity.apache.org>
> Sent: Wednesday, October 29, 2008 8:11 AM
> Subject: special character # in template doesn't work.
>
>
> hi Everyone
>
> Can someone give me a hint why the sample HelloWorld.java (see below) removes
> character # from my banner (see MyBanner.vm). As you see, the result shows all
> my # signs removed from the first line and second line. Is # a special character
> in Velocity? Thanks.
>
> ------------------MyBanner.vm ----------------
> ##########################################
> # #
> # Hello World - Hello World #
> # #
> ##########################################
>
> ------------------- RESULT --------------
> # #
> # Hello World - Hello World #
> # #
>
>
> -------------------- Program HelloWorld.java
>
> import java.io.StringWriter;
> import org.apache.velocity.app.VelocityEngine;
> import org.apache.velocity.Template;
> import org.apache.velocity.VelocityContext;
> public class HelloWorld
> {
> public static void main( String[] args )
> throws Exception
> {
> /* first, get and initialize an engine */
> VelocityEngine ve = new VelocityEngine();
> ve.init();
> /* next, get the Template */
> Template t = ve.getTemplate( "MyBanner.vm" );
> /* create a context and add data */
> VelocityContext context = new VelocityContext();
> context.put("name", "World");
> /* now render the template into a StringWriter */
> StringWriter writer = new StringWriter();
> t.merge( context, writer );
> /* show the World */
> System.out.println( writer.toString() );
> }
> }
>
>
>

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


Mime
View raw message