Try using a string instead of location for ftl rendering to avoid creating a temporary dbresource.
Showing
1 changed file
with
22 additions
and
5 deletions
... | @@ -125,11 +125,28 @@ along with this software (see the LICENSE.md file). If not, see | ... | @@ -125,11 +125,28 @@ along with this software (see the LICENSE.md file). If not, see |
125 | } | 125 | } |
126 | ]]></script> | 126 | ]]></script> |
127 | <!-- <log level="warn" message="dataPre is ${dataPre}"/>--> | 127 | <!-- <log level="warn" message="dataPre is ${dataPre}"/>--> |
128 | <set field="grapesTempFile" from="grapesJsResource.makeFile(grapesFile?.dbResourceId + '.temp.json')"/> | 128 | <script><![CDATA[ |
129 | <script>grapesTempFile.putText(dataPre)</script> | 129 | String location = "template.ftl"; |
130 | <set field="data" from="ec.resource.template(grapesTempFile.location, 'ftl')"/> | 130 | |
131 | <script>grapesTempFile.delete()</script> | 131 | freemarker.template.Template newTemplate; |
132 | <!-- <log level="warn" message="data is ${data}"/>--> | 132 | Reader templateReader = null; |
133 | |||
134 | try { | ||
135 | templateReader = new StringReader(context.dataPre); | ||
136 | // Use the getFtlConfiguration method from ec.resource.templateRenderers.ftl | ||
137 | newTemplate = new freemarker.template.Template(location, templateReader, ec.resource.templateRenderers.ftl.getFtlConfiguration()); | ||
138 | } catch (Exception e) { | ||
139 | throw new org.moqui.BaseArtifactException("Error while initializing template at " + location, e); | ||
140 | } finally { | ||
141 | if (templateReader != null) { | ||
142 | try { templateReader.close(); } | ||
143 | catch (Exception e) { logger.error("Error closing template reader", e); } | ||
144 | } | ||
145 | } | ||
146 | context.data = newTemplate.toString(); | ||
147 | ]]></script> | ||
148 | <!-- <set field="data" from="ec.resource.template(grapesTempFile.location, 'ftl')"/>--> | ||
149 | <log level="warn" message="data is ${data}"/> | ||
133 | <set field="moquiVars" from="globalGrapeVarList"/> | 150 | <set field="moquiVars" from="globalGrapeVarList"/> |
134 | </else-if> | 151 | </else-if> |
135 | <else> | 152 | <else> | ... | ... |
-
Please register or sign in to post a comment