logo       

RE: html macro library: msg#00195

jakarta.velocity.user

Subject: RE: html macro library

Thanks Rodrigo,

That's a great "macro" library idea. It certainly would be
comprehensive and a heck of a lot better that writing one of my own!

Kevin


-----Original Message-----
From: Rodrigo Reyes [mailto:rodrigo@xxxxxxxxxxxxxx]
Sent: Friday, May 30, 2003 1:50 PM
To: Velocity Users List
Subject: Re: html macro library


Hi
I have been using Velocity on a pretty complex website. One of the
things I learned from this project is that maybe the easiest and most
maintainable way to handle the creation of tags inside a template is
using an XML library. For my specific needs, I use JDOM. So when I need
to have a link created I do something like this:

#set($a = $utils.getElement('a'))
$a.setAttributeValue('href', '...')
$a.setAttributeValue(target, '...')
$a.setAttributeValue('onClick', '...')
....
$a.setText('This text is linked to ...')
$utils.toString($a)

I know that those are many lines of code for a simple link, but from
my experience, it's a lot easier to read and maintain. And an Element in
JDOM could also contain other Elements, so I can have that as recursive
as I need.
My 2 c...

Rodrigo

----- Original Message -----
From: "Kevin Bolton" <kbolton@xxxxxxxxxxx>
To: "'Velocity Users List'" <velocity-user@xxxxxxxxxxxxxxxxxx>
Sent: Friday, May 30, 2003 11:38 AM
Subject: RE: html macro library


> Hey Jonathan,
>
> Thank you for your response and I'm with you on the need for
> #directiveA(#directiveB)). It'd also be mighty handy to be able to
> overload methods. That is have methods with the same name with
> different arguments.
>
> I'll look into FreeMarker.
>
> Thanks,
> Kevin
>
> -----Original Message-----
> From: news [mailto:news@xxxxxxxxxxxxxx] On Behalf Of Jonathan Revusky
> Sent: Friday, May 30, 2003 11:34 AM
> To: velocity-user@xxxxxxxxxxxxxxxxxx
> Subject: Re: html macro library
>
>
> Kevin Bolton wrote:
> > Has anyone developed a macro library for standard html items? For
> > example:
> >
> > #macro (html_href $link $text)
> >
> > <a href='$link'>$text</a>
>
> I don't know whether anybody has developed such a library for
> Velocity, but it seems to me that, unless the macros could be applied
> recursively,
>
> such a library would be of very limited use-value. Unfortunately,
> Velocimacros have design problems or limitations that prevent this.
>
> You see, to be generally useful, a block-oriented HTML generating
> macro would have to be able to take a block (containing potentially
> other template directives) as its parameter. That is your $text
> parameter in the above.
>
> FYI, at least one other template engine does afford this possibility.
> FreeMarker has had the ability to define macros with associated blocks

> since version 2.2.
>
> If the Velocity community does resume active development of the
> template
>
> engine, then the above kind of feature is probably well worth lobbying

> them for.
>
> Best Regards,
>
> Jonathan Revusky
> --
> lead developer, FreeMarker project, http://freemarker.org/ FreeMarker
> vs. Velocity comparison page: http://freemarker.org/fmVsVel.html
>
> FreeMarker 2.3 preview 1 is out! :-)
>
>
>
> >
> > #end
> >
> >
> > --------------------
> > Kevin Bolton
> > Paychex Inc
> > (585) 216-0808
> > <mailto:kbolton@paychex>
> >
> >
> >
> >
> > -----------------------------------------
> > The information contained in this message may be privileged,
> > confidential, and protected from disclosure. If the reader of this
> message is not the intended recipient, or any employee or agent
> responsible for delivering this message to the intended recipient, you

> are hereby notified that any dissemination, distribution, or copying
> of this communication is strictly prohibited. If you have received
> this communication in error, please notify us immediately by replying
> to the message and deleting it from your computer.
> >
> > Thank you. Paychex, Inc.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@xxxxxxxxxxxxxxxxxx
> For additional commands, e-mail: velocity-user-help@xxxxxxxxxxxxxxxxxx
>
>
> -----------------------------------------
> The information contained in this message may be privileged,
> confidential,
and protected from disclosure. If the reader of this message is not the
intended recipient, or any employee or agent responsible for delivering
this message to the intended recipient, you are hereby notified that any
dissemination, distribution, or copying of this communication is
strictly prohibited. If you have received this communication in error,
please notify us immediately by replying to the message and deleting it
from your computer.
>
> Thank you. Paychex, Inc.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@xxxxxxxxxxxxxxxxxx
> For additional commands, e-mail: velocity-user-help@xxxxxxxxxxxxxxxxxx
>



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: velocity-user-help@xxxxxxxxxxxxxxxxxx


-----------------------------------------
The information contained in this message may be privileged, confidential, and
protected from disclosure. If the reader of this message is not the intended
recipient, or any employee or agent responsible for delivering this message to
the intended recipient, you are hereby notified that any dissemination,
distribution, or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify us immediately by
replying to the message and deleting it from your computer.

Thank you. Paychex, Inc.


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise