dcsimg
Embedding "sub-templates" in existing code
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Jeff_Stroup
Posted On:   Saturday, August 25, 2007 11:42 AM

Many of the template forms that I want to emit are not singular or complete files but need to be "injected" intelligently in one or more *existing* files. My first inclination was to generate the code fragments and then manually copy and paste them into the existing files. Yuk! I don't have the luxury of generating code from scratch. Is it possible to direct a template to intelligently inject it's output into specific section(s), phrase(s) of a given output file? I thought of re-writing the token buffer in place but I'm not exactly "reading in some source code and writing out a slightly altered version" per section 9.7 of the ANTLR reference. My goal is to generate NEW code WITHIN existing code but whose content is not necessaril   More>>

Many of the template forms that I want to emit are not singular or complete files but need to be "injected" intelligently in one or more *existing* files. My first inclination was to generate the code fragments and then manually copy and paste them into the existing files. Yuk!
I don't have the luxury of generating code from scratch.
Is it possible to direct a template to intelligently inject it's output into specific section(s), phrase(s) of a given output file? I thought of re-writing the token buffer in place but I'm not exactly "reading in some source code and writing out a slightly altered version" per section 9.7 of the ANTLR reference. My goal is to generate NEW code WITHIN existing code but whose content is not necessarily derived from the existing code. I'm not always necessarily going to be "re-writing" the input stream. I'm altering a very large struts app and want to quickly add, say, an HTML component of some kind to, say, a detail page. The code to do this, or any such web app component addition, is typically strewn amongst several source files. You have to add the HTML (or equivelent)component to the impl JSP, maybe some supporting Javascript, JSTL logic, hidden fields... Then you may need to add code to the Struts Action and ActionForm, perhaps add a method or phrase to a helper file, add a key/value pair to the resource bundle, add an action mapping or form to stuts-config.xml, or possibly modify tiles-def.xml. Whew! I am confident that I can (eventually) generate the needed grammar to generate the proper text forms for various tasks, but how do I get the output to end up in the right places?

Thanks

   <<Less
About | Sitemap | Contact