Making a macro library part of a data model?
Chris <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
I've got a bit of an odd use-case.
We've got a custom data model that changes behavior based on user
parameters:
[@aFancyDirective version="123"/]
Depending on the version number, we want to import a particular macro
library into a template so it's available to the designer.
We had been doing it using Configuration.addAutoInclude(), but now that
we need to implement different versions, it would be a lot cleaner for
us to handle it in the data model.
Right now, our data model looks like this:
public class DataModel implements TemplateHashModel {
public Object get(Object key) {
if (key.equals("foo")) {
return someStuff;
} else if (key.equals("bar")) {
return otherStuff;
}
}
}
We'd like to make it so that if key.equals("someMacro") then we can
return the macro. Is it possible to load the macro library into a
template, and then somehow find the macro in the template and return it
in response to a get()?
------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software
be a part of the solution? Download the Intel(R) Manageability Checker
today! http://p.sf.net/sfu/intel-dev2devmar