[ 
https://issues.apache.org/jira/browse/VELTOOLS-97?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12569999#action_12569999
 ] 

Christopher Schultz commented on VELTOOLS-97:
---------------------------------------------

I'm wondering how much better this is than simply building the markup yourself.

(Sorry that I always seem to be a naysayer around here!)

I realize that you need lots of if/then/else for skipping empty attributes, 
etc. in this case, but one of the things that always bothers me about toolkits 
like this is that they tend to suffer from tremendous bloat. Granted, every 
single thing in Velocity Tools /could/ be implemented using some of the more 
basic "building blocks" provided by Velocity itself (as well as shoving certain 
useful objects into the context beforehand), but this just seems like another 
excuse to increase the number of tools available.

In terms of the specifics of your tool idea, I'm wondering how you'll get the 
tool to generate the correct tag (such as "img" versus "foo"). Does the tool 
implement a factory-ish method called "get" that returns a tag object that can 
then have its attributes set?

> MarkupTool
> ----------
>
>                 Key: VELTOOLS-97
>                 URL: https://issues.apache.org/jira/browse/VELTOOLS-97
>             Project: Velocity Tools
>          Issue Type: New Feature
>          Components: GenericTools
>    Affects Versions: 2.x
>            Reporter: Nathan Bubna
>            Priority: Minor
>             Fix For: 2.x
>
>
> As i grow continually more fond of tools and less fond of macros (though 
> things are finally starting to look up for macros in 1.6 and the possibility 
> of Raghu implementing blockmacros), i find myself starting to wish for tools 
> that aid with markup (mostly html or xml).  The idea has occurred to me that 
> i might find a general MarkupTool for manipulating markup in flexible, 
> repeatable ways.   The API i have in mind might be used something like this:
> #set( $foo = $markup.foo.attr('bar', 0) )
> $foo
> #if( $foo.bar == 0 )
> $foo.body($text.danger).attr({'black' : 'white', 'zebras' : $crossing})
> #end
> which would output
> <foo bar="0"/>
> <foo bar="0" black="white" zebras="crossing">Danger!</foo>
> It's also not hard to imagine ways to allow default attributes/values for 
> various tags in the configuration for the tool, like 
> <tool class="org.apache.velocity.tools.generic.MarkupTool" 
> img="border:0,class:thumb"/>
> So that doing just
> $markup.img.attr('src',$imglink)
> would produce something like
> <img border="0" class="thumb" src="http://foo.com/bar.jpg"/>
> Granted, i don't have that many situations where this would be useful, but 
> there have been a few.  Also, i wonder if it might serve as a base class for 
> a JSPTaglibTool (see  
> http://velocity.markmail.org/search/?q=jsp+tag#query:jsp%20tag%20from%3A%22Nathan%20Bubna%22+page:2+mid:ebotko7hanut3uhx+state:results
>  for more on this)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to