JET2 - declaring custom tags [message #4416] |
Wed, 14 March 2007 15:31  |
Eclipse User |
|
|
|
Originally posted by: vincent.lg.voila.fr
Hi everyone,
I just discovered new JET2 capabilities and I would like to use it in my
project.
I followed the IBM's tutorial
( http://www-128.ibm.com/developerworks/opensource/library/os- ecl-jet/) and
doing simple transformations works right now.
My question is : how to extend JET2 by declaring my own custom tags ?
I tried to add a extension point (org.eclipse.jet.tagLibrairies) and
implement a HelloWorldTag.java as my custom tag, but when I call this
newly tag in the dump.jet, it just prints out my tag (ie. the tag is not
recognized by the parser)
Have anyone ever tried to declare custom tags ? How can I do that ?
Thanks in advance !
|
|
|
Re: JET2 - declaring custom tags [message #5361 is a reply to message #4416] |
Wed, 21 March 2007 14:22  |
Paul Elder Messages: 849 Registered: July 2009 |
Senior Member |
|
|
All:
This thread has mostly resolved itself, but, for good measure, here's a
summary:
* Custom JET tags are created by creating a plug-in project, adding a
dependency on org.eclipse.jet, and creating an org.eclipse.jet.tagLibraries
extension
* The id of the tag library is the plug-in id + dot + the id you specify in
the tagLibrary element
* There are several kinds of custom tags:
* empty (e.g. <mytags:myempty a1="..."/>) - typically used to write
content to the template output. JET example: c:get
* function (eg. <mytags:myfunc a1="...">some text</mytags:myfunc>) -
used to modify the content of the tag. JET example: f:lc
* container (e.g. <mytags:mycontainer>some
content</mytags:mycontainer) - more advanced processing of a tag contents.
JET Example: c:choose
* conditional (e.g. <mytags:mycond>some cond content</mytags:mycond) -
conditionally process the tag contents. JET Example: c:if
* iterating (e.g. <mytags:myiter>some repeated
content</mytags:myiter) - iteraratively process the tag contents. JET
Example: c:iterate
* Each custom tag is backed by a Java class. The extension point is setup to
create the classes that extend abstract classes that do much of the work.
See the documentation for org.eclipse.jet.taglib.AbstractXxxTag and also the
interfaces defining the tags org.eclipse.jet.taglib.XxxTag
To use a custom tag library in a JET transformation you have two choices:
a) in your transformation, open plugin.xml, go to the Extension tab, and on
the org.eclipse.jet.transform extension (plugin.xml), under
(transform)/(taglibraries), and a new importLibrary, specifying the tag
library id and prefix, and set autoImport to true.
b) individually in JET templates via the <%@ taglib id="library id"
prefix="mytags" %> directive
Paul
"Vincent" <vincent.lg@voila.fr> wrote in message
news:245d4d85ac00c04b1974cf013726ef94$1@www.eclipse.org...
> Hi everyone,
> I just discovered new JET2 capabilities and I would like to use it in my
> project.
> I followed the IBM's tutorial
> ( http://www-128.ibm.com/developerworks/opensource/library/os- ecl-jet/) and
> doing simple transformations works right now.
>
> My question is : how to extend JET2 by declaring my own custom tags ?
> I tried to add a extension point (org.eclipse.jet.tagLibrairies) and
> implement a HelloWorldTag.java as my custom tag, but when I call this
> newly tag in the dump.jet, it just prints out my tag (ie. the tag is not
> recognized by the parser)
>
> Have anyone ever tried to declare custom tags ? How can I do that ?
>
> Thanks in advance !
|
|
|
Powered by
FUDForum. Page generated in 0.02327 seconds