Template Loaders and Acquisition Mechanism
Darko Radosevic <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Hi, we have templates placed in folder hierarchy (default/client/site) and we're using default FileTemplateLoader and acquisition mechanism to load templates. But now we want to introduce a brand new type of templates - templates for mobile site. The mobile templates should follow this same default/client/site hierarchy but they should take precedence over regular templates when the request is coming from a mobile device. We could diferrentiate mobile templates by placing in separate folder or by "m_" name prefix, we haven't decided yet. So, loading order on a mobile site should be: 1. mobile site template 2.mobile client 3 mobile default 4.standard site 5 standard client 6.standard default This looks tricky to solve, I've first tried to utilize MultiTemplateLoader and some custom TemplateLoaders, but I would get only this loading order: 1. mobile site 2.standard site 3.mobile client 4. standard client 5. mobile default 6.standard default. The only working solution I've found so far is to use two Configurations, each having different base folder. In case 'mobile' Configuration throws FileNotFoundException, try to use 'standard' Configuration. The problem with this solution is that we'll need copy all templates from the 'standard' folder to the 'mobile' folder and then maintain duplicates. The only other possible solution I see is to rewrite TemplateCache to maybe somehow move acquisition mechanism inside template loader, but this looks way too low-level... Do you know of any cases where TemplateCache is overwritten with some diferrent implementation, or do you know of some Freemarker features that could be useful for me? Thanks, Darko ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ FreeMarker-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/freemarker-user