|
Re: Best place for utility code in jet templates [message #420582 is a reply to message #420574] |
Wed, 02 July 2008 17:01 |
Ed Merks Messages: 33141 Registered: July 2009 |
Senior Member |
|
|
Gary,
Comments below.
gary thompson wrote:
> Dear All
>
>
> What strategies do people use to hide utility code away in JET templates?
Don't put them in the templates. :-P
> Here is one. Currency I am overriding header.javajetinc and creating
> an instance of a utility class defined there. However this seems hacky
> and fragile as there is no guarantee that the header file will be
> included in the same method as later parts of the template are called
> in (and I believe this is the case as I had to make my util variable
> final to make it globally visible). Further more an instance needs to
> be created and you can't use imports and static methods... so this is
> a bit messy.
Yes, JET is not so easily extensible. Some will argue that Xpand is
nicer...
>
> My other approach would be to define the utility classes compile them
> and then put them on the classpath of the .JETEmitters project.
> However, it is not clear how to do this (at least not to me)
This would be cleaner. The "Template Plugin Variables" property of the
GenModel could be used to specify these additional plugin dependencies
for the .JETEmitters project; you might have to delete that project for
them to take effect...
>
>
> regards
> gary
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03469 seconds