You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Keng Wong <ke...@verizon.net> on 2001/01/15 22:52:07 UTC

Parsing an include

Hi,
I have been using Freemarker and it's a great tool to build
and customize web sites. I have been looking at Velocity
and has a question about parsing.
In Freemarker, I normally does the following:

In leftnavigation.html:

...
<include "nav-shoppingcart.html">
...
<include "nav-1800number.html">
...

This way, I can insert 'objects' into any screen and the
inserted object (screen) may have dynamic content (shop
cart in this case). I read that Velocity currently does
not support parsing of objects that are included. Any
other way to perform what I'm doing now ? Any hints ?
The idea is to reduce redundancy (eg. may need to
insert the shop cart in various navigation templates)

Thanks in advance.

Re: layoutsnull

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Matthew King wrote:
> 
> I'm trying to get Velocity running with an existing Turbine site, but I keep
> running into the same problem:
> 
> java.lang.Exception: TurbineTemplateService: getLayoutTemplateName() was
> passed in a null value.

I am no turbine guru, but this looks like a turbine config problem as
it's trying to get a template from the bin directory, which means the
velocity defaults are in effect : the default path to load templates
from is .

I would take this to the turbine list...

geir
 
> When I look in the velocity log, I can see this:
> 
> Tue Jan 16 15:39:52 PST 2001   [info] Velocity successfully started.
> Tue Jan 16 15:40:30 PST 2001   [info] Attempting to find layoutsnull with
> org.apache.velocity.runtime.resource.loader.FileResourceLoader
> Tue Jan 16 15:40:30 PST 2001  [error] FileResourceLoader Error: cannot find
> resource C:\sandbox\webapps\ROOT\templates\layoutsnull
> Tue Jan 16 15:40:30 PST 2001   [info] Attempting to find layoutsnull with
> org.apache.velocity.runtime.resource.loader.FileResourceLoader
> Tue Jan 16 15:40:30 PST 2001  [error] FileResourceLoader Error: cannot find
> resource C:\sandbox\bin\.\layoutsnull
> Tue Jan 16 15:40:30 PST 2001  [error] java.lang.Exception: Can't find
> layoutsnull!
> Tue Jan 16 15:40:30 PST 2001  [error] Template.merge() failure. The document
> is null, most likely due to parsing error.
> 
> Where is the 'layoutsnull' coming from?  I have tried tweaking various
> settings in turbineResources.properties without any luck.
> 
> Any help would be appreciated!

-- 
Geir Magnusson Jr.                               geirm@optonline.com
Velocity : it's not just a good idea. It should be the law.
http://jakarta.apache.org/velocity

layoutsnull

Posted by Matthew King <md...@aracnet.com>.
I'm trying to get Velocity running with an existing Turbine site, but I keep
running into the same problem:

java.lang.Exception: TurbineTemplateService: getLayoutTemplateName() was
passed in a null value.

When I look in the velocity log, I can see this:

Tue Jan 16 15:39:52 PST 2001   [info] Velocity successfully started.
Tue Jan 16 15:40:30 PST 2001   [info] Attempting to find layoutsnull with
org.apache.velocity.runtime.resource.loader.FileResourceLoader
Tue Jan 16 15:40:30 PST 2001  [error] FileResourceLoader Error: cannot find
resource C:\sandbox\webapps\ROOT\templates\layoutsnull
Tue Jan 16 15:40:30 PST 2001   [info] Attempting to find layoutsnull with
org.apache.velocity.runtime.resource.loader.FileResourceLoader
Tue Jan 16 15:40:30 PST 2001  [error] FileResourceLoader Error: cannot find
resource C:\sandbox\bin\.\layoutsnull
Tue Jan 16 15:40:30 PST 2001  [error] java.lang.Exception: Can't find
layoutsnull!
Tue Jan 16 15:40:30 PST 2001  [error] Template.merge() failure. The document
is null, most likely due to parsing error.

Where is the 'layoutsnull' coming from?  I have tried tweaking various
settings in turbineResources.properties without any luck.

Any help would be appreciated!


Re: Parsing an include

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Keng Wong wrote:
> 
> Geir,
> Thanks - it works! BTW, what is velocimacro ? Is this on the website ?


A velocimacro ('VM') is a little 'named defintion' of template language
that you can then reuse.  The best analogy is a function call, but we
don't use that phrase here :)

They are defined as such, in your template or in a central library :

#macro(  myvm $arg $blarg $flarg)

  Hello $arg.

  #foreach($i in $blarg )
    $flarg = $i
  #end
#end

and used in your template as if it's a new directive :

#set($a = "foo")
#set($b = ["a", "b", "c"] )
#set($c = "bloo")
#myvm( $a $b $c )


and the output would be

Hello foo

bloo = a
bloo = b
bloo = c

The point is that anything that can be in a template can be put into the
body of a VM.

Think of them simply as cut-and-paste, with the references (or
constants) used when calling the VM pasted into the VMs body.

geir

> -----Original Message-----
> From: gmj@optonline.net [mailto:gmj@optonline.net]On Behalf Of Geir
> Magnusson Jr.
> Sent: Monday, January 15, 2001 2:41 PM
> To: velocity-user@jakarta.apache.org
> Subject: Re: Parsing an include
> 
> Keng Wong wrote:
> >
> > Hi,
> > I have been using Freemarker and it's a great tool to build
> > and customize web sites. I have been looking at Velocity
> > and has a question about parsing.
> > In Freemarker, I normally does the following:
> >
> > In leftnavigation.html:
> >
> > ...
> > <include "nav-shoppingcart.html">
> > ...
> > <include "nav-1800number.html">
> > ...
> >
> > This way, I can insert 'objects' into any screen and the
> > inserted object (screen) may have dynamic content (shop
> > cart in this case). I read that Velocity currently does
> > not support parsing of objects that are included. Any
> > other way to perform what I'm doing now ? Any hints ?
> > The idea is to reduce redundancy (eg. may need to
> > insert the shop cart in various navigation templates)
> >
> > Thanks in advance.
> 
> It does.  use #parse( filename )
> 
> If you want real fun and funky, look at the Velocimacro functionality
> too....
> 
> --
> Geir Magnusson Jr.                               geirm@optonline.com
> Velocity : it's not just a good idea. It should be the law.
> http://jakarta.apache.org/velocity

-- 
Geir Magnusson Jr.                               geirm@optonline.com
Velocity : it's not just a good idea. It should be the law.
http://jakarta.apache.org/velocity

RE: Parsing an include

Posted by Keng Wong <ke...@verizon.net>.
Geir,
Thanks - it works! BTW, what is velocimacro ? Is this on the website ?

-----Original Message-----
From: gmj@optonline.net [mailto:gmj@optonline.net]On Behalf Of Geir
Magnusson Jr.
Sent: Monday, January 15, 2001 2:41 PM
To: velocity-user@jakarta.apache.org
Subject: Re: Parsing an include


Keng Wong wrote:
> 
> Hi,
> I have been using Freemarker and it's a great tool to build
> and customize web sites. I have been looking at Velocity
> and has a question about parsing.
> In Freemarker, I normally does the following:
> 
> In leftnavigation.html:
> 
> ...
> <include "nav-shoppingcart.html">
> ...
> <include "nav-1800number.html">
> ...
> 
> This way, I can insert 'objects' into any screen and the
> inserted object (screen) may have dynamic content (shop
> cart in this case). I read that Velocity currently does
> not support parsing of objects that are included. Any
> other way to perform what I'm doing now ? Any hints ?
> The idea is to reduce redundancy (eg. may need to
> insert the shop cart in various navigation templates)
> 
> Thanks in advance.

It does.  use #parse( filename )

If you want real fun and funky, look at the Velocimacro functionality
too....

-- 
Geir Magnusson Jr.                               geirm@optonline.com
Velocity : it's not just a good idea. It should be the law.
http://jakarta.apache.org/velocity

Re: Parsing an include

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Keng Wong wrote:
> 
> Hi,
> I have been using Freemarker and it's a great tool to build
> and customize web sites. I have been looking at Velocity
> and has a question about parsing.
> In Freemarker, I normally does the following:
> 
> In leftnavigation.html:
> 
> ...
> <include "nav-shoppingcart.html">
> ...
> <include "nav-1800number.html">
> ...
> 
> This way, I can insert 'objects' into any screen and the
> inserted object (screen) may have dynamic content (shop
> cart in this case). I read that Velocity currently does
> not support parsing of objects that are included. Any
> other way to perform what I'm doing now ? Any hints ?
> The idea is to reduce redundancy (eg. may need to
> insert the shop cart in various navigation templates)
> 
> Thanks in advance.

It does.  use #parse( filename )

If you want real fun and funky, look at the Velocimacro functionality
too....

-- 
Geir Magnusson Jr.                               geirm@optonline.com
Velocity : it's not just a good idea. It should be the law.
http://jakarta.apache.org/velocity

Re: Parsing an include

Posted by Jon Stevens <jo...@latchkey.com>.
on 1/15/01 1:52 PM, "Keng Wong" <ke...@verizon.net> wrote:

> Hi,
> I have been using Freemarker and it's a great tool to build
> and customize web sites. I have been looking at Velocity
> and has a question about parsing.
> In Freemarker, I normally does the following:
> 
> In leftnavigation.html:
> 
> ...
> <include "nav-shoppingcart.html">
> ...
> <include "nav-1800number.html">
> ...
> 
> This way, I can insert 'objects' into any screen and the
> inserted object (screen) may have dynamic content (shop
> cart in this case). I read that Velocity currently does
> not support parsing of objects that are included. Any
> other way to perform what I'm doing now ? Any hints ?
> The idea is to reduce redundancy (eg. may need to
> insert the shop cart in various navigation templates)
> 
> Thanks in advance.

Ok, the documentation wasn't updated on the website. Please look now...

<http://jakarta.apache.org/velocity/user-guide.html>

-jon

-- 
Honk if you love peace and quiet.