[stringtemplate-interest] Group Syntax extension for ModelAdapter and Renderer
ub at abego-software.de
Tue Jun 21 01:17:42 PDT 2011
currently we programmatically register ModelAdapters and Renderers to an STGroup.
What about providing an extension to the syntax of Group to also define these in a Group file?
E.g. I could imagine to use something like
adapter "org.w3c.dom.Node" "com.collinfagan.strum.adapters.xml.NodeModelAdapter"
renderer "org.w3c.dom.Node" "com.collinfagan.strum.adapters.xml.NodeRenderer"
at the top of an Group file. This would mean the same as running this Java code for the group:
group.registerRenderer(org.w3c.dom.Node.class, new com.collinfagan.strum.adapters.xml.NodeRenderer());
group.registerModelAdaptor(org.w3c.dom.Node.class, new com.collinfagan.strum.adapters.xml.NodeModelAdapter());
Especially when importing groups this feature comes in handy as I cannot register adapters/renderers when importing. In these cases I must rely on the root group. For this group R we must register ALL adapters/renders used in ANY group R imports. This make things hard to maintain as using a "new" renderer in some template T requires me to add the "registerRenderer" in EVERY code using T, maybe indirectly through imports.
Similar to features discussed earlier this feature is easy to implement for the STGroupFile, but the STGroupDir currently has no proper place to hold this information. So we may also need to tackle this re-appearing topic, too.
What do others think?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the stringtemplate-interest