You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Thomas Fahrmeyer <th...@einsurance.de> on 2001/02/01 09:56:27 UTC
Features are complete ?
I think there is one feature that is very nice to have.
I discussed this with Geir few days ago under the thread:
Re: AW: How can I compile and insert a external text ??
I should be able to parse the template stuff from any InputStream and the
result should be the parsed and expanded template.
String text = UtilityClass.parse(inputstream);
It does all the merging stuff. The parser has the functionality, but it's
not very well exposed. This not complicated, but usefull if I store the
templates in a database for example or it comes from other external
applications.
What do you think ?
bye
Thomas
Re: Features are complete ?
Posted by Christoph Reck <Ch...@dlr.de>.
Geir, could you pelase post the code of your #eval directive, maybe to
the whiteboard? Thanks.
Thomas, you can use this code to create your own directive that does
that then. OK, stop here..., I see you want to do this from the java
code... either:
a. just get a SimpleNode via Runtime.parse(inputStream, name), then
init(ica, null) it and finally render(ica, writer) it;
b. implement your own Resource - see Template.java on how to.
c. if you want resource cachning implement a ResourceLoader.
Probably the best (if a. is not sufficient) is to subclass Template
and provide your own ResourceLoader for it.
:) Chirstoph
Thomas Fahrmeyer wrote:
>
> I think there is one feature that is very nice to have.
>
> I discussed this with Geir few days ago under the thread:
> Re: AW: How can I compile and insert a external text ??
>
> I should be able to parse the template stuff from any InputStream and the
> result should be the parsed and expanded template.
>
> String text = UtilityClass.parse(inputstream);
>
> It does all the merging stuff. The parser has the functionality, but it's
> not very well exposed. This not complicated, but usefull if I store the
> templates in a database for example or it comes from other external
> applications.
>
> What do you think ?
>
> bye
> Thomas
Re: AW: AW: Features are complete ?
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Thomas Fahrmeyer wrote:
>
> Hi,
>
> yeah it works in the way I expected and it seems that I can drop my own
> class ;)
>
> Here yet a little suggestion:
> - Can add a parameter: templateName to the calls. If the templateName is
> referenced in log-files, it's certainly useful if the app can set this name
> at runtime.
Yep
> - A more grained exception handling. Log Messages for ParseException and the
> other exceptions which can be fired. (I know the code you provided is a
> first snapshot ;)
Yep
> Thanx for your fast response
>
> Thomas
>
> > -----Ursprungliche Nachricht-----
> > Von: gmj@optonline.net [mailto:gmj@optonline.net]Im Auftrag von Geir
> > Magnusson Jr.
> > Gesendet: Donnerstag, 1. Februar 2001 20:48
> > An: velocity-user@jakarta.apache.org
> > Betreff: Re: AW: Features are complete ?
> >
> >
> > Ok. I just checked into the whiteboard a new class : Velocity.java
> >
> > To get it, update your CVS tree, or just use the online CVS browser to
> > download a copy.
> >
> > NOTE : this should be dropped into your source tree in
> > src/java/org/apache/velocity/util
> >
> > The point of this class is to become the application utility class. I
> > hope that it might :
> >
> > 1) Be the interface to the velocity core, so we can wean application
> > programmers from calling Runtime methods directly. This would decouple
> > the Velocity application API from the internal implementation, making
> > life better for all.
> >
> > 2) providing both useful and interesting application-level utility
> > functions that we want to support.
> >
> > Anyhow, Thomas et al, give the evaluate() function a try...
> >
> > I used it thus :
> >
> > context.put("Floog", "floogie woogie");
> > context.put("name", "geir");
> >
> > String stest = " My name is $name -> $Floog";
> > StringWriter w = new StringWriter();
> >
> > Velocity.evaluate( context, w, stest );
> >
> > System.out.println("Eval = " + w );
> >
> > let us know how it works...
> >
> > geir
> >
> >
> > "Geir Magnusson Jr." wrote:
> > >
> > > Jon Stevens wrote:
> > > >
> > > > on 2/1/01 9:44 AM, "Thomas Fahrmeyer" <th...@einsurance.de>
> > > > wrote:
> > > >
> > > > > Hmm, I'm confused too ;))
> > > > >
> > > > > I got the nightly build (02/01/01) and can't find any
> > > > > InputStreamTemplateLoader ;(
> > > > >
> > > > > It sounds as if that is what I want to have. I build
> > something similar by
> > > > > myself.
> > > > >
> > > > > bye
> > > > > Thomas
> > > >
> > > > Exactly. I'm saying to you that that is the right way to
> > implement such
> > > > functionality. I'm not saying that it already exists.
> > >
> > > I'm not sure about this, y'all. I think that as it's an application
> > > type of thing that seems to be needed, then an application API type of
> > > solution would be good. What I mean by this is that he doesn't need any
> > > of the 'infrastructure' to do this.
> > >
> > > I am testing now an eval() function in the Velocity helper class not to
> > > be used in a template, but in the Java code w/o any real difficulty.
> > >
> > > it's public boolean evaluate( Context, Writer, String)
> > > or public boolean evaluate( Context, Writer, InputStream)
> > >
> > > If I can remember to import correctly, I will have this in the
> > > whiteboard in the next few minutes...
> > >
> > > --
> > > 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
--
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: AW: AW: Features are complete ?
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
New version in whiteboard...
Thomas Fahrmeyer wrote:
>
> Hi,
>
> yeah it works in the way I expected and it seems that I can drop my own
> class ;)
>
> Here yet a little suggestion:
> - Can add a parameter: templateName to the calls. If the templateName is
> referenced in log-files, it's certainly useful if the app can set this name
> at runtime.
>
> - A more grained exception handling. Log Messages for ParseException and the
> other exceptions which can be fired. (I know the code you provided is a
> first snapshot ;)
>
> Thanx for your fast response
>
> Thomas
>
> > -----Ursprungliche Nachricht-----
> > Von: gmj@optonline.net [mailto:gmj@optonline.net]Im Auftrag von Geir
> > Magnusson Jr.
> > Gesendet: Donnerstag, 1. Februar 2001 20:48
> > An: velocity-user@jakarta.apache.org
> > Betreff: Re: AW: Features are complete ?
> >
> >
> > Ok. I just checked into the whiteboard a new class : Velocity.java
> >
> > To get it, update your CVS tree, or just use the online CVS browser to
> > download a copy.
> >
> > NOTE : this should be dropped into your source tree in
> > src/java/org/apache/velocity/util
> >
> > The point of this class is to become the application utility class. I
> > hope that it might :
> >
> > 1) Be the interface to the velocity core, so we can wean application
> > programmers from calling Runtime methods directly. This would decouple
> > the Velocity application API from the internal implementation, making
> > life better for all.
> >
> > 2) providing both useful and interesting application-level utility
> > functions that we want to support.
> >
> > Anyhow, Thomas et al, give the evaluate() function a try...
> >
> > I used it thus :
> >
> > context.put("Floog", "floogie woogie");
> > context.put("name", "geir");
> >
> > String stest = " My name is $name -> $Floog";
> > StringWriter w = new StringWriter();
> >
> > Velocity.evaluate( context, w, stest );
> >
> > System.out.println("Eval = " + w );
> >
> > let us know how it works...
> >
> > geir
> >
> >
> > "Geir Magnusson Jr." wrote:
> > >
> > > Jon Stevens wrote:
> > > >
> > > > on 2/1/01 9:44 AM, "Thomas Fahrmeyer" <th...@einsurance.de>
> > > > wrote:
> > > >
> > > > > Hmm, I'm confused too ;))
> > > > >
> > > > > I got the nightly build (02/01/01) and can't find any
> > > > > InputStreamTemplateLoader ;(
> > > > >
> > > > > It sounds as if that is what I want to have. I build
> > something similar by
> > > > > myself.
> > > > >
> > > > > bye
> > > > > Thomas
> > > >
> > > > Exactly. I'm saying to you that that is the right way to
> > implement such
> > > > functionality. I'm not saying that it already exists.
> > >
> > > I'm not sure about this, y'all. I think that as it's an application
> > > type of thing that seems to be needed, then an application API type of
> > > solution would be good. What I mean by this is that he doesn't need any
> > > of the 'infrastructure' to do this.
> > >
> > > I am testing now an eval() function in the Velocity helper class not to
> > > be used in a template, but in the Java code w/o any real difficulty.
> > >
> > > it's public boolean evaluate( Context, Writer, String)
> > > or public boolean evaluate( Context, Writer, InputStream)
> > >
> > > If I can remember to import correctly, I will have this in the
> > > whiteboard in the next few minutes...
> > >
> > > --
> > > 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
--
Geir Magnusson Jr. geirm@optonline.com
Velocity : it's not just a good idea. It should be the law.
http://jakarta.apache.org/velocity
AW: AW: Features are complete ?
Posted by Thomas Fahrmeyer <th...@einsurance.de>.
Hi,
yeah it works in the way I expected and it seems that I can drop my own
class ;)
Here yet a little suggestion:
- Can add a parameter: templateName to the calls. If the templateName is
referenced in log-files, it's certainly useful if the app can set this name
at runtime.
- A more grained exception handling. Log Messages for ParseException and the
other exceptions which can be fired. (I know the code you provided is a
first snapshot ;)
Thanx for your fast response
Thomas
> -----Ursprungliche Nachricht-----
> Von: gmj@optonline.net [mailto:gmj@optonline.net]Im Auftrag von Geir
> Magnusson Jr.
> Gesendet: Donnerstag, 1. Februar 2001 20:48
> An: velocity-user@jakarta.apache.org
> Betreff: Re: AW: Features are complete ?
>
>
> Ok. I just checked into the whiteboard a new class : Velocity.java
>
> To get it, update your CVS tree, or just use the online CVS browser to
> download a copy.
>
> NOTE : this should be dropped into your source tree in
> src/java/org/apache/velocity/util
>
> The point of this class is to become the application utility class. I
> hope that it might :
>
> 1) Be the interface to the velocity core, so we can wean application
> programmers from calling Runtime methods directly. This would decouple
> the Velocity application API from the internal implementation, making
> life better for all.
>
> 2) providing both useful and interesting application-level utility
> functions that we want to support.
>
> Anyhow, Thomas et al, give the evaluate() function a try...
>
> I used it thus :
>
> context.put("Floog", "floogie woogie");
> context.put("name", "geir");
>
> String stest = " My name is $name -> $Floog";
> StringWriter w = new StringWriter();
>
> Velocity.evaluate( context, w, stest );
>
> System.out.println("Eval = " + w );
>
> let us know how it works...
>
> geir
>
>
> "Geir Magnusson Jr." wrote:
> >
> > Jon Stevens wrote:
> > >
> > > on 2/1/01 9:44 AM, "Thomas Fahrmeyer" <th...@einsurance.de>
> > > wrote:
> > >
> > > > Hmm, I'm confused too ;))
> > > >
> > > > I got the nightly build (02/01/01) and can't find any
> > > > InputStreamTemplateLoader ;(
> > > >
> > > > It sounds as if that is what I want to have. I build
> something similar by
> > > > myself.
> > > >
> > > > bye
> > > > Thomas
> > >
> > > Exactly. I'm saying to you that that is the right way to
> implement such
> > > functionality. I'm not saying that it already exists.
> >
> > I'm not sure about this, y'all. I think that as it's an application
> > type of thing that seems to be needed, then an application API type of
> > solution would be good. What I mean by this is that he doesn't need any
> > of the 'infrastructure' to do this.
> >
> > I am testing now an eval() function in the Velocity helper class not to
> > be used in a template, but in the Java code w/o any real difficulty.
> >
> > it's public boolean evaluate( Context, Writer, String)
> > or public boolean evaluate( Context, Writer, InputStream)
> >
> > If I can remember to import correctly, I will have this in the
> > whiteboard in the next few minutes...
> >
> > --
> > 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: AW: Features are complete ?
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Ok. I just checked into the whiteboard a new class : Velocity.java
To get it, update your CVS tree, or just use the online CVS browser to
download a copy.
NOTE : this should be dropped into your source tree in
src/java/org/apache/velocity/util
The point of this class is to become the application utility class. I
hope that it might :
1) Be the interface to the velocity core, so we can wean application
programmers from calling Runtime methods directly. This would decouple
the Velocity application API from the internal implementation, making
life better for all.
2) providing both useful and interesting application-level utility
functions that we want to support.
Anyhow, Thomas et al, give the evaluate() function a try...
I used it thus :
context.put("Floog", "floogie woogie");
context.put("name", "geir");
String stest = " My name is $name -> $Floog";
StringWriter w = new StringWriter();
Velocity.evaluate( context, w, stest );
System.out.println("Eval = " + w );
let us know how it works...
geir
"Geir Magnusson Jr." wrote:
>
> Jon Stevens wrote:
> >
> > on 2/1/01 9:44 AM, "Thomas Fahrmeyer" <th...@einsurance.de>
> > wrote:
> >
> > > Hmm, I'm confused too ;))
> > >
> > > I got the nightly build (02/01/01) and can't find any
> > > InputStreamTemplateLoader ;(
> > >
> > > It sounds as if that is what I want to have. I build something similar by
> > > myself.
> > >
> > > bye
> > > Thomas
> >
> > Exactly. I'm saying to you that that is the right way to implement such
> > functionality. I'm not saying that it already exists.
>
> I'm not sure about this, y'all. I think that as it's an application
> type of thing that seems to be needed, then an application API type of
> solution would be good. What I mean by this is that he doesn't need any
> of the 'infrastructure' to do this.
>
> I am testing now an eval() function in the Velocity helper class not to
> be used in a template, but in the Java code w/o any real difficulty.
>
> it's public boolean evaluate( Context, Writer, String)
> or public boolean evaluate( Context, Writer, InputStream)
>
> If I can remember to import correctly, I will have this in the
> whiteboard in the next few minutes...
>
> --
> 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: AW: Features are complete ?
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Jon Stevens wrote:
>
> on 2/1/01 9:44 AM, "Thomas Fahrmeyer" <th...@einsurance.de>
> wrote:
>
> > Hmm, I'm confused too ;))
> >
> > I got the nightly build (02/01/01) and can't find any
> > InputStreamTemplateLoader ;(
> >
> > It sounds as if that is what I want to have. I build something similar by
> > myself.
> >
> > bye
> > Thomas
>
> Exactly. I'm saying to you that that is the right way to implement such
> functionality. I'm not saying that it already exists.
I'm not sure about this, y'all. I think that as it's an application
type of thing that seems to be needed, then an application API type of
solution would be good. What I mean by this is that he doesn't need any
of the 'infrastructure' to do this.
I am testing now an eval() function in the Velocity helper class not to
be used in a template, but in the Java code w/o any real difficulty.
it's public boolean evaluate( Context, Writer, String)
or public boolean evaluate( Context, Writer, InputStream)
If I can remember to import correctly, I will have this in the
whiteboard in the next few minutes...
--
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: AW: Features are complete ?
Posted by Jon Stevens <jo...@latchkey.com>.
on 2/1/01 9:44 AM, "Thomas Fahrmeyer" <th...@einsurance.de>
wrote:
> Hmm, I'm confused too ;))
>
> I got the nightly build (02/01/01) and can't find any
> InputStreamTemplateLoader ;(
>
> It sounds as if that is what I want to have. I build something similar by
> myself.
>
> bye
> Thomas
Exactly. I'm saying to you that that is the right way to implement such
functionality. I'm not saying that it already exists.
-jon
AW: Features are complete ?
Posted by Thomas Fahrmeyer <th...@einsurance.de>.
Hmm, I'm confused too ;))
I got the nightly build (02/01/01) and can't find any
InputStreamTemplateLoader ;(
It sounds as if that is what I want to have. I build something similar by
myself.
bye
Thomas
> -----Ursprungliche Nachricht-----
> Von: Jon Stevens [mailto:jon@latchkey.com]
> Gesendet: Donnerstag, 1. Februar 2001 18:24
> An: velocity-user@jakarta.apache.org
> Betreff: Re: Features are complete ?
>
>
> on 2/1/01 12:56 AM, "Thomas Fahrmeyer" <th...@einsurance.de>
> wrote:
>
> > I think there is one feature that is very nice to have.
> >
> > I discussed this with Geir few days ago under the thread:
> > Re: AW: How can I compile and insert a external text ??
> >
> > I should be able to parse the template stuff from any
> InputStream and the
> > result should be the parsed and expanded template.
> >
> > String text = UtilityClass.parse(inputstream);
> >
> > It does all the merging stuff. The parser has the
> functionality, but it's
> > not very well exposed. This not complicated, but usefull if I store the
> > templates in a database for example or it comes from other external
> > applications.
> >
> > What do you think ?
> >
> > bye
> > Thomas
>
> Uh. I'm confused. Where is the Context set? Why can't you use a
> InputStreamTemplateLoader to do this?
>
> -jon
>
Re: Features are complete ?
Posted by Jon Stevens <jo...@latchkey.com>.
on 2/1/01 12:56 AM, "Thomas Fahrmeyer" <th...@einsurance.de>
wrote:
> I think there is one feature that is very nice to have.
>
> I discussed this with Geir few days ago under the thread:
> Re: AW: How can I compile and insert a external text ??
>
> I should be able to parse the template stuff from any InputStream and the
> result should be the parsed and expanded template.
>
> String text = UtilityClass.parse(inputstream);
>
> It does all the merging stuff. The parser has the functionality, but it's
> not very well exposed. This not complicated, but usefull if I store the
> templates in a database for example or it comes from other external
> applications.
>
> What do you think ?
>
> bye
> Thomas
Uh. I'm confused. Where is the Context set? Why can't you use a
InputStreamTemplateLoader to do this?
-jon