Re: FreeMarker Processing Pipeline
Attila Szegedi <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
I'm not entirely sure what do you consider a "processing pipeline", but I'll take a guess... - template source code is pulled from whatever resources by an instance of a class implementing freemarker.cache.TemplateLoader - (there is a MultiTemplateLoader to multiplex several loaders into one) - TemplateLoader is owned by a freemarker.cache.TemplateCache and used to load template source code on demand. TemplateCache will also create a new Template object and pass it its source code; and store the constructed Template object for later retrieval. The Template object builds the AST from its source code and stores it internally. - TemplateCache is owned by a Configuration object. When you render output through a Template, you invoke the Template.process(), passing it the data model and an output writer. Under the cover, a thread local object, freemarker.core.Environment is created, which act as the context for the duration of that particular process() invocation and coordinates the rendering to the writer. If you want a preprocessor, your best bet (at least in 2.3.x codebase) is to create a TemplateLoader that wraps another one, and edits the source code of the templates. In the 2.4.x codebase, there is an AST visitor API that you can use to do logical transformation on the AST level; you register the AST visitors with the Configuration, and they're each given a chance to manipulate the AST after it's initially constructed. Attila. On 2008.05.28., at 21:15, mraible wrote: > > Is the FreeMarker Processing Pipeline documented somewhere. It would > be very > useful to see a diagram. The reason I'm asking is because I'd like > to insert > a pre-processing phase. I have a templating framework that allows > replacing > standard HTML tags, i.e. , , etc. with macros, jsp tags or > whatnot. I'd > like to use it with FreeMarker to simplify page authoring for web > developers. > > Thanks, > > Matt ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/