You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Lukas Zimmermann <lu...@liebhart.com> on 2001/12/03 13:54:09 UTC

lil parser bug?

Hi all.

I have a template like this:

$to.test("a test string")LITERAL

which renders correctly to this:

<a test string>LITERAL

BUT in the log a warning is recorded:

[warn] org.apache.velocity.runtime.exception.ReferenceException:
reference : template = test.vm [line 1,column 26] :
LITERAL is not a valid reference.

If I insert a space behind the closing parenthesis
(or if the reference is enclosed with braces), things work
without warning.
(I checked this with velocity 1.2-rc3 and older releases.)

Is this the behaviour to expect?

Greets,
Lukas

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Nested templates with nested contexts

Posted by Martin Stepanek <ab...@wo.cz>.
> > Maybe it's my englishs fault - it's a little bit jerky, I know
> :o) I've only
> > meant it would be nice to have directive like
>
> No, the english is fine.  I haven't had enough coffee yet (on the
> east coast
> of US...)

You seem to be fully stretched here on the mailing list. Maybe, you should
take a walk and relax a bit :o)

> > #parse "$template" using $context
> >
> > and everything else would be business of the underlying servlet code.
> >
> > Martin
>
> There are ways to do this but require a little more work on your part.
>
> For example, you could make a little tool, a simple class that
> has a method
>
>   public String contextParse( String template, <something> )
>
> For you to use from your template.  You could contruct the data you need
> somehow in the template, and pass that to the method :
>
>   $thingy.contextParse( $template, $object)
>
> Where $object has all of the data you need.
>
> And in the java code, the contextParse() method just takes the passed-in
> data, adds that to a fresh context, and uses the VelocityEngine.evaluate()
> method to render the template.
>
> Just another example...

Wow! This is exactly, what I want... and what I was asking for :o)

> The tricky/annoying thing might be assembling that data....  I don't know
> enough about your proble to know what that might be like.

I don't thing the data assembling should be problem -- in fact I have
already preliminary methods for building the data structures. Maybe I'll
have problems rather with writing the code for communicating the tool with
Velocity, but it seems to be simple according to your instruction. IAC I'll
give it a try...

Again, thank you very much for your help...

Martin





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Nested templates with nested contexts

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/4/01 9:07 AM, "Martin Stepanek" <ab...@wo.cz> wrote:

>> Well, you could define a bunch of VMs, corresponding to each of the above,
>> and have the VMs invoke the correct VM for the person found, having a main
>> VM that handles the recursion.
>> 
>> So the recursion is only in one place, and the 'rendering' VMs
>> take care of
>> the formatting, and then recurse using the main VM.
> 
> Maybe this is the way to go. I will think about it...
> 
>>> I think the best solution would be, if all that context-setting
>> stuff would
>>> transact the controller, ie. the servlet java program. The
>> template should
>>> only contain the reference to the template and the actual
>> nested context...
>>> Hmmm, do I want too much? :o)
>> 
>> I don't understand the last bit...
> 
> Maybe it's my englishs fault - it's a little bit jerky, I know :o) I've only
> meant it would be nice to have directive like

No, the english is fine.  I haven't had enough coffee yet (on the east coast
of US...)

> 
> #parse "$template" using $context
> 
> and everything else would be business of the underlying servlet code.
> 
> Martin

There are ways to do this but require a little more work on your part.

For example, you could make a little tool, a simple class that has a method

  public String contextParse( String template, <something> )

For you to use from your template.  You could contruct the data you need
somehow in the template, and pass that to the method :

  $thingy.contextParse( $template, $object)

Where $object has all of the data you need.

And in the java code, the contextParse() method just takes the passed-in
data, adds that to a fresh context, and uses the VelocityEngine.evaluate()
method to render the template.

Just another example...

The tricky/annoying thing might be assembling that data....  I don't know
enough about your proble to know what that might be like.


-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"He who throws mud only loses ground." - Fat Albert


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Nested templates with nested contexts

Posted by Martin Stepanek <ab...@wo.cz>.
> Well, you could define a bunch of VMs, corresponding to each of the above,
> and have the VMs invoke the correct VM for the person found, having a main
> VM that handles the recursion.
>
> So the recursion is only in one place, and the 'rendering' VMs
> take care of
> the formatting, and then recurse using the main VM.

Maybe this is the way to go. I will think about it...

> > I think the best solution would be, if all that context-setting
> stuff would
> > transact the controller, ie. the servlet java program. The
> template should
> > only contain the reference to the template and the actual
> nested context...
> > Hmmm, do I want too much? :o)
>
> I don't understand the last bit...

Maybe it's my englishs fault - it's a little bit jerky, I know :o) I've only
meant it would be nice to have directive like

#parse "$template" using $context

and everything else would be business of the underlying servlet code.

Martin


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Nested templates with nested contexts

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/4/01 8:19 AM, "Martin Stepanek" <ab...@wo.cz> wrote:

>> You'll fit well in here then, because we aren't either... :)
> 
> Fine, so here's the next round. This solution was much better, but still not
> exactly what I need. Sorry, I really don't wanna abuse you :o) If you're
> tired feel free to ignore me :o)

We aim to please...
> 
>> Here is were our Velocimacros really shine, because there is a switch that
>> turns on 'local context', which means new references created in the VM are
>> local to that VM.  So I would recast as
>> 
>> 
>> #macro( gentree  $person )
>> 
>>   #if( $person  )
>> 
>>     #set($this = $person )
>>     Name: $this.name
>> 
>>     Child data :
>>       #gentree( $this.child )
>> 
>>     Address: $this.address
>> 
>>   #end
>> #end
> 
> In this concrete case it's definitely perfect, but ... The template
> structure should be as much flexible as possible. I'll try to invent another
> sample. Something like that (more complex absurd genealogic tree):
> 
> root.vm
> 
> Name: $root.name
> 
> Children:
> #foreach $child in $root.children
>   #parse ($child.gender) with $this = $child
> #end
> 
> Address: $root.address
> --
> 
> male.vm
> 
> Name: $this.name
> 
> Children:
> #foreach $child in $root.children
>   #parse ($child.gender) with $this = $child
> #end
> 
> Favorite automobile make: $child.car
> --
> 
> female.vm
> 
> Name: $this.name
> 
> Children:
> #foreach $child in $root.children
>   #parse ($child.gender) with $this = $child
> #end
> 
> Favorite lipstick color: $child.lipstick
> --
> 
> I used imaginary "with" clause of #parse directive to make it simple. It
> could be of course much more complicated, and it probably will be in reality
> :o) I could maybe include different files with macro gentree ... one file
> would be for females, one for males ... but it would fail in the case one
> person would have children of both genders (which is quite common :o).

Well, you could define a bunch of VMs, corresponding to each of the above,
and have the VMs invoke the correct VM for the person found, having a main
VM that handles the recursion.

So the recursion is only in one place, and the 'rendering' VMs take care of
the formatting, and then recurse using the main VM.


> 
> I think the best solution would be, if all that context-setting stuff would
> transact the controller, ie. the servlet java program. The template should
> only contain the reference to the template and the actual nested context...
> Hmmm, do I want too much? :o)

I don't understand the last bit...

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Nested templates with nested contexts

Posted by Martin Stepanek <ab...@wo.cz>.
> You'll fit well in here then, because we aren't either... :)

Fine, so here's the next round. This solution was much better, but still not
exactly what I need. Sorry, I really don't wanna abuse you :o) If you're
tired feel free to ignore me :o)

> Here is were our Velocimacros really shine, because there is a switch that
> turns on 'local context', which means new references created in the VM are
> local to that VM.  So I would recast as
>
>
> #macro( gentree  $person )
>
>   #if( $person  )
>
>     #set($this = $person )
>     Name: $this.name
>
>     Child data :
>       #gentree( $this.child )
>
>     Address: $this.address
>
>   #end
> #end

In this concrete case it's definitely perfect, but ... The template
structure should be as much flexible as possible. I'll try to invent another
sample. Something like that (more complex absurd genealogic tree):

root.vm

 Name: $root.name

 Children:
  #foreach $child in $root.children
    #parse ($child.gender) with $this = $child
  #end

 Address: $root.address
--

male.vm

 Name: $this.name

 Children:
  #foreach $child in $root.children
    #parse ($child.gender) with $this = $child
  #end

  Favorite automobile make: $child.car
--

female.vm

 Name: $this.name

 Children:
  #foreach $child in $root.children
    #parse ($child.gender) with $this = $child
  #end

  Favorite lipstick color: $child.lipstick
--

I used imaginary "with" clause of #parse directive to make it simple. It
could be of course much more complicated, and it probably will be in reality
:o) I could maybe include different files with macro gentree ... one file
would be for females, one for males ... but it would fail in the case one
person would have children of both genders (which is quite common :o).

I think the best solution would be, if all that context-setting stuff would
transact the controller, ie. the servlet java program. The template should
only contain the reference to the template and the actual nested context...
Hmmm, do I want too much? :o)

Regards
Martin




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Nested templates with nested contexts

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/4/01 7:05 AM, "Martin Stepanek" <ab...@wo.cz> wrote:

> Thank for your reply. Nevertheless, I still have some questions and notes to
> your solution (OK, I'm that never satisfied perfectionist guy :o)...

You'll fit well in here then, because we aren't either... :)

> 
>> ...
>> maps, each map containing the necessary data for each inclusion :
>> 
>> #foreach( $data in $datamaplist )
>>    #set( $includedata = $data )
>>    #parse( "thetemplate.vm" )
>> #end
>> 
>> But I suspect that you already thought of this and rejected it for some
>> reason?
> 
> Yes, you're right. Maybe I overlooked something, but consider this case (I
> need just one recursively nested template to illustrate, what goes
> wrong...):
> 
> The template (it's absurd example, but I hope intelligible enough) named
> "gentree.vm" could look like this:
> 
> Name: $person.name
> 
> Child data:
>  #set( $person = $person.child)
>  #parse( "gentree.vm" )
> 
> Address: $person.address
> 
> If I understand it well, then in the address won't be the data of the right
> person, but the data of the last (leaf) child in the tree... Which is too
> bad.
> 
> The use of Velocimacro is certainly appropriate, when you need include
> relatively simple structure on many different places with different
> parameters. But, when you need more complex hierarchical structure, where
> every template can dynamically include (or better to say: parse :o) other
> nested templates, which can include arbitrary nested templates too, and so
> on, then the Velocimacro IMHO won't help you...

I am not sure that's a fair conclusion.  I assume that the above tempalte is
the full gentree.vm, and it is #parse()-ing itself.

What you have seems to be a recursive problem - you want to walk down and
display a tree.

You can do it with #parse() - #parse() works fine recursively, but you have
the problem that you can 'step on' your own context.

I.e. As you noted, $person will get stepped on on the way down, so when you
come out of the #parse() the wrong $person.address will be rendered...

Here is were our Velocimacros really shine, because there is a switch that
turns on 'local context', which means new references created in the VM are
local to that VM.  So I would recast as


#macro( gentree  $person )

  #if( $person  )
  
    #set($this = $person )
    Name: $this.name

    Child data :
      #gentree( $this.child )

    Address: $this.address
  
  #end
#end

With the added #if() to stop the recursion when you run out of children...

I just typed that in w/o trying it, so there may be some problem in
implementation, but it does work.

>>> The concept of Velocity is very similar to concept of Webmacro,
>> but the two
>>> products aren't exactly the same.
>> 
>> We certainly think so :)
> 
> But I think both are great :o) Oh, and I'm such a irresolute man! I'm afraid
> I never make up my mind which one to use :o)

Life is full of difficult choices. :)
 
>> I think if we had a better idea  of what the problem was, that
>> would help...
> 
> I tried to explain it... Hope, I was at least partly successful...
>

This example was better :)

-- 
Geir Magnusson Jr.                       geirm@optonline.net
System and Software Consulting
You're going to end up getting pissed at your software
anyway, so you might as well not pay for it. Try Open Source.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Nested templates with nested contexts

Posted by Martin Stepanek <ab...@wo.cz>.
Thank for your reply. Nevertheless, I still have some questions and notes to
your solution (OK, I'm that never satisfied perfectionist guy :o)...

> ...
> maps, each map containing the necessary data for each inclusion :
>
> #foreach( $data in $datamaplist )
>    #set( $includedata = $data )
>    #parse( "thetemplate.vm" )
> #end
>
> But I suspect that you already thought of this and rejected it for some
> reason?

Yes, you're right. Maybe I overlooked something, but consider this case (I
need just one recursively nested template to illustrate, what goes
wrong...):

 The template (it's absurd example, but I hope intelligible enough) named
"gentree.vm" could look like this:

  Name: $person.name

  Child data:
   #set( $person = $person.child)
   #parse( "gentree.vm" )

  Address: $person.address

If I understand it well, then in the address won't be the data of the right
person, but the data of the last (leaf) child in the tree... Which is too
bad.

The use of Velocimacro is certainly appropriate, when you need include
relatively simple structure on many different places with different
parameters. But, when you need more complex hierarchical structure, where
every template can dynamically include (or better to say: parse :o) other
nested templates, which can include arbitrary nested templates too, and so
on, then the Velocimacro IMHO won't help you...

> > The concept of Velocity is very similar to concept of Webmacro,
> but the two
> > products aren't exactly the same.
>
> We certainly think so :)

But I think both are great :o) Oh, and I'm such a irresolute man! I'm afraid
I never make up my mind which one to use :o)

> I think if we had a better idea  of what the problem was, that
> would help...

I tried to explain it... Hope, I was at least partly successful...

Have a nice day
Martin



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Nested templates with nested contexts

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/3/01 9:31 AM, "Martin Stepanek" <ab...@wo.cz> wrote:

> Hi all!
> 
> Recently I started to use Webmacro for merging templates with data. The
> concept was hierarchical tree structure of nested templates. It seems to
> work fine, till I've came across a big problem: I needed to include the same
> template in one page more times and with different data each case. I didn't
> find any feature, which would enable to include nested templates with
> parameters or nested contexts (which makes no essential difference).

There are some obvious solutions, such as iterating the number of times
needed and setting into the context some glob of data - if you had a list of
maps, each map containing the necessary data for each inclusion :

#foreach( $data in $datamaplist )
   #set( $includedata = $data )
   #parse( "thetemplate.vm" )
#end

But I suspect that you already thought of this and rejected it for some
reason?
 
Can you give an illustration of what you are trying to do?

We have a facility called a 'Velocimacro' which is a parameterized
invocation of a template (so to speak... I change the description to suit :)

It works like this.  You define the VM (Velocimacro) as follows, with
whatever name of course and arglist you want...

#macro( themacro $arg1 $arg2 $list )

   This is arg1 : $arg1
   This is arg2 : $arg2

    #foreach( $item in $list)
        Item $velocityCount : $item
    #end
#end

So you get the idea...

Then, you can invoke with whatever parameters you want :


#themacro( "hello" $woogie [1..10] )

#themacro( true 11 $myNameList )


So this would be one way to include with different data many times.  The
nice part is that it's clear what's going on.  The only downside I can think
of is that the data needed is a huge, long list, in which case this would be
unwieldly.


> 
> The concept of Velocity is very similar to concept of Webmacro, but the two
> products aren't exactly the same.

We certainly think so :)

> So, I hope, maybe there is some solution
> to this problem in Velocity, when Webmacro fails here. (In Webmacro was
> directive filter, which should solve this, but unfortunatelly, it isn't
> implemented in the current version).
> 
> Have you any idea?
> 

I think if we had a better idea  of what the problem was, that would help...



-- 
Geir Magnusson Jr.                       geirm@optonline.net
System and Software Consulting
You're going to end up getting pissed at your software
anyway, so you might as well not pay for it. Try Open Source.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: pulling my hair out - parse templates

Posted by pero <pe...@antaramusic.de>.
Hi,

oh sh**, I found the problem, but I would expect it to work. If I use
Velocity the "normal" way (Velocity.getTemplate()... Velocity.mergeTemplate
(template, sw)) then the parse works! But I use Velocity.evaluate(), because
most times I parse thinks I construct in my app... And then it doesn't work
(the parse-thing). Is there any way around?

pero

> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
> Sent: Tuesday, December 04, 2001 2:46 PM
> To: velocity-user@jakarta.apache.org
> Subject: Re: pulling my hair out - parse templates
>
>
> On 12/4/01 8:34 AM, "pero" <pe...@antaramusic.de> wrote:
>
> > Hi,
> >
> >> On 12/3/01 9:53 AM, "pero" <pe...@antaramusic.de> wrote:
> >>
> >>> Hi there,
> >>>
> >>> I started using velocity and everything works fine (after
> >> figuring out some
> >>> things like escaping issues and stuff - with help of this list!)
> >>> But now I'm stuck. I try to use the #parse-directive but it
> >> does not work. I
> >>> always get a "cannot find thanks.vm template!" error in my
> log. I nearly
> >>> tried everything (again with help of this list) - I've set
> >>> file.resource.loader.path with relative absolute paths, I've
> >> put an absolute
> >>> path in the parse-statement, but it doesn't work. Now I'm a bit
> >>> "confused"... Everything worked "out of the box" and so I got
> >> used to it :)
> >>> and thus: "pulling my hair out" :)
> >>>
> >>> help is really appreciated - thanks in advance!
> >>>
> >>
> >> We need some more details.
> >>
> >> 1) What are the values used for 'fil.resource.loader.path'
> >
> > The App runs in o:/runenv the templates reside in
> o:/runenv/templates (in
> > several subdirectories) I tried the following (one after another)
> > file.resource.loader.path=o:/runenv
> > file.resource.loader.path=o:/runenv/templates
> > file.resource.loader.path=.
> > file.resource.loader.path=templates
> >
> >> 2) Is this an app or servlet?
> >
> > An App.
> >
> >> 3) Where are the templates located
> >
> > o:/runenv/templates is the general directory. The template I
> parse from my
> > app is o:/runenv/templates/new/display.vm
> > the one I want to parse within that template is
> > o:/runenv/templates/default/display.vm
> >
> >> 4) What is the argument to #parse()?
> >
> > According to each line in 1):
> > #parse ("templates/default/display.vm")
> > #parse ("default/display.vm")
> > #parse ("templates/default/display.vm")
> > #parse ("default/display.vm")
> >
> > Hope that helps (to help me :)
> >
>
>
> Weird.
>
> 1) Can we see the log?
>
> 2) can you try to not set anything related to
> "file.resource....", and then
> starting your app in the o:/runenv directory,
>
>   #parse( "templates/default/display.vm")
>
> I would think this would work.
>
> The log will help.
>
>
>
> --
> Geir Magnusson Jr.     geirm@optonline.net
> System and Software Consulting
> "Whoever would overthrow the liberty of a nation must begin by
> subduing the
> freeness of speech." - Benjamin Franklin
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: pulling my hair out - parse templates

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/4/01 8:34 AM, "pero" <pe...@antaramusic.de> wrote:

> Hi,
> 
>> On 12/3/01 9:53 AM, "pero" <pe...@antaramusic.de> wrote:
>> 
>>> Hi there,
>>> 
>>> I started using velocity and everything works fine (after
>> figuring out some
>>> things like escaping issues and stuff - with help of this list!)
>>> But now I'm stuck. I try to use the #parse-directive but it
>> does not work. I
>>> always get a "cannot find thanks.vm template!" error in my log. I nearly
>>> tried everything (again with help of this list) - I've set
>>> file.resource.loader.path with relative absolute paths, I've
>> put an absolute
>>> path in the parse-statement, but it doesn't work. Now I'm a bit
>>> "confused"... Everything worked "out of the box" and so I got
>> used to it :)
>>> and thus: "pulling my hair out" :)
>>> 
>>> help is really appreciated - thanks in advance!
>>> 
>> 
>> We need some more details.
>> 
>> 1) What are the values used for 'fil.resource.loader.path'
> 
> The App runs in o:/runenv the templates reside in o:/runenv/templates (in
> several subdirectories) I tried the following (one after another)
> file.resource.loader.path=o:/runenv
> file.resource.loader.path=o:/runenv/templates
> file.resource.loader.path=.
> file.resource.loader.path=templates
> 
>> 2) Is this an app or servlet?
> 
> An App.
> 
>> 3) Where are the templates located
> 
> o:/runenv/templates is the general directory. The template I parse from my
> app is o:/runenv/templates/new/display.vm
> the one I want to parse within that template is
> o:/runenv/templates/default/display.vm
> 
>> 4) What is the argument to #parse()?
> 
> According to each line in 1):
> #parse ("templates/default/display.vm")
> #parse ("default/display.vm")
> #parse ("templates/default/display.vm")
> #parse ("default/display.vm")
> 
> Hope that helps (to help me :)
> 


Weird.

1) Can we see the log?

2) can you try to not set anything related to "file.resource....", and then
starting your app in the o:/runenv directory,

  #parse( "templates/default/display.vm")

I would think this would work.

The log will help.



-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: pulling my hair out - parse templates

Posted by pero <pe...@antaramusic.de>.
Hi,

> On 12/3/01 9:53 AM, "pero" <pe...@antaramusic.de> wrote:
>
> > Hi there,
> >
> > I started using velocity and everything works fine (after
> figuring out some
> > things like escaping issues and stuff - with help of this list!)
> > But now I'm stuck. I try to use the #parse-directive but it
> does not work. I
> > always get a "cannot find thanks.vm template!" error in my log. I nearly
> > tried everything (again with help of this list) - I've set
> > file.resource.loader.path with relative absolute paths, I've
> put an absolute
> > path in the parse-statement, but it doesn't work. Now I'm a bit
> > "confused"... Everything worked "out of the box" and so I got
> used to it :)
> > and thus: "pulling my hair out" :)
> >
> > help is really appreciated - thanks in advance!
> >
>
> We need some more details.
>
> 1) What are the values used for 'fil.resource.loader.path'

The App runs in o:/runenv the templates reside in o:/runenv/templates (in
several subdirectories) I tried the following (one after another)
file.resource.loader.path=o:/runenv
file.resource.loader.path=o:/runenv/templates
file.resource.loader.path=.
file.resource.loader.path=templates

> 2) Is this an app or servlet?

An App.

> 3) Where are the templates located

o:/runenv/templates is the general directory. The template I parse from my
app is o:/runenv/templates/new/display.vm
the one I want to parse within that template is
o:/runenv/templates/default/display.vm

> 4) What is the argument to #parse()?

According to each line in 1):
#parse ("templates/default/display.vm")
#parse ("default/display.vm")
#parse ("templates/default/display.vm")
#parse ("default/display.vm")

Hope that helps (to help me :)

thanks,
pero


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: pulling my hair out - parse templates

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/3/01 9:53 AM, "pero" <pe...@antaramusic.de> wrote:

> Hi there,
> 
> I started using velocity and everything works fine (after figuring out some
> things like escaping issues and stuff - with help of this list!)
> But now I'm stuck. I try to use the #parse-directive but it does not work. I
> always get a "cannot find thanks.vm template!" error in my log. I nearly
> tried everything (again with help of this list) - I've set
> file.resource.loader.path with relative absolute paths, I've put an absolute
> path in the parse-statement, but it doesn't work. Now I'm a bit
> "confused"... Everything worked "out of the box" and so I got used to it :)
> and thus: "pulling my hair out" :)
> 
> help is really appreciated - thanks in advance!
> 

We need some more details.

1) What are the values used for 'fil.resource.loader.path'

2) Is this an app or servlet?

3) Where are the templates located

4) What is the argument to #parse()?

geir

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


pulling my hair out - parse templates

Posted by pero <pe...@antaramusic.de>.
Hi there,

I started using velocity and everything works fine (after figuring out some
things like escaping issues and stuff - with help of this list!)
But now I'm stuck. I try to use the #parse-directive but it does not work. I
always get a "cannot find thanks.vm template!" error in my log. I nearly
tried everything (again with help of this list) - I've set
file.resource.loader.path with relative absolute paths, I've put an absolute
path in the parse-statement, but it doesn't work. Now I'm a bit
"confused"... Everything worked "out of the box" and so I got used to it :)
and thus: "pulling my hair out" :)

help is really appreciated - thanks in advance!

pero


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Nested templates with nested contexts

Posted by Martin Stepanek <ab...@wo.cz>.
Hi all!

Recently I started to use Webmacro for merging templates with data. The
concept was hierarchical tree structure of nested templates. It seems to
work fine, till I've came across a big problem: I needed to include the same
template in one page more times and with different data each case. I didn't
find any feature, which would enable to include nested templates with
parameters or nested contexts (which makes no essential difference).

The concept of Velocity is very similar to concept of Webmacro, but the two
products aren't exactly the same. So, I hope, maybe there is some solution
to this problem in Velocity, when Webmacro fails here. (In Webmacro was
directive filter, which should solve this, but unfortunatelly, it isn't
implemented in the current version).

Have you any idea?

Thanx
Martin


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: lil parser bug?

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/3/01 7:54 AM, "Lukas Zimmermann" <lu...@liebhart.com>
wrote:

> Hi all.
> 
> I have a template like this:
> 
> $to.test("a test string")LITERAL
> 
> which renders correctly to this:
> 
> <a test string>LITERAL
> 
> BUT in the log a warning is recorded:
> 
> [warn] org.apache.velocity.runtime.exception.ReferenceException:
> reference : template = test.vm [line 1,column 26] :
> LITERAL is not a valid reference.

That¹s a bug :)
> 
> If I insert a space behind the closing parenthesis
> (or if the reference is enclosed with braces), things work
> without warning.
> (I checked this with velocity 1.2-rc3 and older releases.)
> 
> Is this the behaviour to expect?

No - thanks for reporting it.  Will fix.

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
Be a giant.  Take giant steps.  Do giant things...


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>