You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Erlend Simonsen <er...@aspiro.com> on 2007/06/05 14:02:20 UTC

Problem with multi-line comments in 1.5..

I'm in the process of upgading our install of Velocity 1.3.1 to 1.5, but 
I'm running into a problem with multi-line comments.

Basically, in a few cases, I'm getting the *# end marker of a multi-line 
comment printed into my HTML output. This only seems to happen when the 
comment is inside a foreach loop, but I'm not 100% positive. (It doesn't 
happen in all foreach loops at least.)

I have also been unsuccessful in creating a simple example triggering 
this problem, so this is probably some edge case, but it's annoying and 
I'd rather not have to go through all templates and convert to 
single-line comments.


One of the templates that bug out looks something like this:
-----------------------
#parse a.vsp
#parse b.vsp

#macro (c)

    #foreach ($a in $list)
    #end

    #parse c.vsp

    #foreach ($ in $list)
       #* my end of comment markers are printed *#
       #if (something)
           #macroPrintingA
       # else
           #macroPrintingC
       # end
    #end
#end

#c

----------------


Which gives me an output like this:
*#A
*#A
*#C
*#C
*#A
*#...


If I move the comment outside the foreach, it works correctly. It also 
works fine if I move it to the upper foreach.

Any ideas?

-- Erlend Simonsen

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


Re: Problem with multi-line comments in 1.5..

Posted by Will Glass-Husain <wg...@gmail.com>.
This does sound frustrating.  A candidate for Velocity 1.5.1.

I'm trying to catch up on some Velocity-related stuff this week; let me take
a look at this.

WILL

On 6/5/07, Nathan Bubna <nb...@gmail.com> wrote:
>
> On 6/5/07, Erlend Simonsen <er...@aspiro.com> wrote:
> > I'm in the process of upgading our install of Velocity 1.3.1 to 1.5, but
> > I'm running into a problem with multi-line comments.
> >
> > Basically, in a few cases, I'm getting the *# end marker of a multi-line
> > comment printed into my HTML output. This only seems to happen when the
> > comment is inside a foreach loop, but I'm not 100% positive. (It doesn't
> > happen in all foreach loops at least.)
> >
> > I have also been unsuccessful in creating a simple example triggering
> > this problem, so this is probably some edge case, but it's annoying and
> > I'd rather not have to go through all templates and convert to
> > single-line comments.
> >
> >
> > One of the templates that bug out looks something like this:
> > -----------------------
> > #parse a.vsp
> > #parse b.vsp
> >
> > #macro (c)
> >
> >     #foreach ($a in $list)
> >     #end
> >
> >     #parse c.vsp
> >
> >     #foreach ($ in $list)
> >        #* my end of comment markers are printed *#
> >        #if (something)
> >            #macroPrintingA
> >        # else
> >            #macroPrintingC
> >        # end
> >     #end
> > #end
> >
> > #c
> >
> > ----------------
> >
> >
> > Which gives me an output like this:
> > *#A
> > *#A
> > *#C
> > *#C
> > *#A
> > *#...
> >
> >
> > If I move the comment outside the foreach, it works correctly. It also
> > works fine if I move it to the upper foreach.
> >
> > Any ideas?
>
> Only that this is really weird and that i wish one of the more
> parser-savvy devs (Henning? Will? Geir?) would comment.  I stumbled
> across essentially the same issue while i was trying to find a
> reliable workaround for
> http://issues.apache.org/jira/browse/VELOCITY-537.
>
> Something is rotten when it comes to parsing multi-line comments in
> complex macro/foreach structures.
>
> I'm going to be focused on VelocityTools for a couple weeks.  After
> that, if things are still slow with my company, i'll try to find some
> time to dig into the parser and learn enough to figure out what's
> going wrong.
>
> > -- Erlend Simonsen
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: dev-help@velocity.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
> For additional commands, e-mail: dev-help@velocity.apache.org
>
>


-- 
Forio Business Simulations

Will Glass-Husain
wglass@forio.com
www.forio.com

Re: Problem with multi-line comments in 1.5..

Posted by Nathan Bubna <nb...@gmail.com>.
On 6/5/07, Erlend Simonsen <er...@aspiro.com> wrote:
> I'm in the process of upgading our install of Velocity 1.3.1 to 1.5, but
> I'm running into a problem with multi-line comments.
>
> Basically, in a few cases, I'm getting the *# end marker of a multi-line
> comment printed into my HTML output. This only seems to happen when the
> comment is inside a foreach loop, but I'm not 100% positive. (It doesn't
> happen in all foreach loops at least.)
>
> I have also been unsuccessful in creating a simple example triggering
> this problem, so this is probably some edge case, but it's annoying and
> I'd rather not have to go through all templates and convert to
> single-line comments.
>
>
> One of the templates that bug out looks something like this:
> -----------------------
> #parse a.vsp
> #parse b.vsp
>
> #macro (c)
>
>     #foreach ($a in $list)
>     #end
>
>     #parse c.vsp
>
>     #foreach ($ in $list)
>        #* my end of comment markers are printed *#
>        #if (something)
>            #macroPrintingA
>        # else
>            #macroPrintingC
>        # end
>     #end
> #end
>
> #c
>
> ----------------
>
>
> Which gives me an output like this:
> *#A
> *#A
> *#C
> *#C
> *#A
> *#...
>
>
> If I move the comment outside the foreach, it works correctly. It also
> works fine if I move it to the upper foreach.
>
> Any ideas?

Only that this is really weird and that i wish one of the more
parser-savvy devs (Henning? Will? Geir?) would comment.  I stumbled
across essentially the same issue while i was trying to find a
reliable workaround for
http://issues.apache.org/jira/browse/VELOCITY-537.

Something is rotten when it comes to parsing multi-line comments in
complex macro/foreach structures.

I'm going to be focused on VelocityTools for a couple weeks.  After
that, if things are still slow with my company, i'll try to find some
time to dig into the parser and learn enough to figure out what's
going wrong.

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

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