Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
moqui
/
moqui-mjml
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
c50af2e1
authored
2024-05-17 15:24:04 -0500
by
acetousk
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Actually render the data with ftl in memory
1 parent
bb08ed19
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
7 deletions
service/mjml/MjmlServices.xml
service/mjml/MjmlServices.xml
View file @
c50af2e
...
...
@@ -87,10 +87,30 @@ along with this software (see the LICENSE.md file). If not, see
}
]]>
</script>
<!-- <log level="warn" message="dataPre is ${dataPre}"/>-->
<set
field=
"grapesTempFile"
from=
"grapesJsResource.makeFile(grapesFile?.dbResourceId + '.temp.json')"
/>
<script>
grapesTempFile.putText(dataPre)
</script>
<set
field=
"data"
from=
"ec.resource.template(grapesTempFile.location, 'ftl')"
/>
<script>
grapesTempFile.delete()
</script>
<script>
<![CDATA[
String location = "template.ftl";
freemarker.template.Template newTemplate;
Reader templateReader = null;
try {
templateReader = new StringReader(context.dataPre);
// Use the getFtlConfiguration method from ec.resource.templateRenderers.ftl
newTemplate = new freemarker.template.Template(location, templateReader, ec.resource.templateRenderers.ftl.getFtlConfiguration());
} catch (Exception e) {
throw new org.moqui.BaseArtifactException("Error while initializing template at " + location, e);
} finally {
if (templateReader != null) {
try { templateReader.close(); }
catch (Exception e) { logger.error("Error closing template reader", e); }
}
}
StringWriter sw = new StringWriter()
try {
newTemplate.createProcessingEnvironment(ec.contextStack, sw).process();
} catch (Exception e) { throw new org.moqui.BaseArtifactException("Error rendering template at " + location, e); }
context.data = sw.toString();
]]>
</script>
<!-- <log level="warn" message="data is ${data}"/>-->
<set
field=
"moquiVars"
from=
"globalGrapeVarList"
/>
</then>
...
...
@@ -143,10 +163,13 @@ along with this software (see the LICENSE.md file). If not, see
catch (Exception e) { logger.error("Error closing template reader", e); }
}
}
context.data = newTemplate.toString();
StringWriter sw = new StringWriter()
try {
newTemplate.createProcessingEnvironment(ec.contextStack, sw).process();
} catch (Exception e) { throw new org.moqui.BaseArtifactException("Error rendering template at " + location, e); }
context.data = sw.toString();
]]>
</script>
<!-- <set field="data" from="ec.resource.template(grapesTempFile.location, 'ftl')"/>-->
<log
level=
"warn"
message=
"data is ${data}"
/>
<!-- <log level="warn" message="data is ${data}"/>-->
<set
field=
"moquiVars"
from=
"globalGrapeVarList"
/>
</else-if>
<else>
...
...
Please
register
or
sign in
to post a comment