384b5832 by Michael Jones

Merge branch 'BF-11979' into 'master'

Bf 11979

See merge request !2
2 parents 3169a2e4 312f9bfe
......@@ -16,7 +16,9 @@ along with this software (see the LICENSE.md file). If not, see
<extend-entity entity-name="EmailTemplate" package="moqui.basic.email">
<field name="grapesLocation" type="text-medium"/>
<field name="grapesPublishedVersionName" type="text-short"/>
<field name="htmlLocation" type="text-medium"/>
<field name="htmlPublishedVersionName" type="text-short"/>
</extend-entity>
<view-entity entity-name="ProductStoreEmailDetail" package="mantle.product.store">
<member-entity entity-alias="PSE" entity-name="mantle.product.store.ProductStoreEmail"/>
......
......@@ -17,11 +17,34 @@ along with this software (see the LICENSE.md file). If not, see
<actions>
<entity-find-one entity-name="moqui.basic.email.EmailTemplate" value-field="emailTemplate" auto-field-map="[emailTemplateId:emailTemplateId]"/>
<if condition="!emailTemplate">
<if condition="!emailTemplate || !emailTemplate.htmlLocation">
<return error="true" message="Email Template not found"/>
</if>
<set field="dataPre" from="ec.resource.getLocationReference(emailTemplate.htmlLocation).getText(emailTemplate.htmlPublishedVersionName)"/>
<script><![CDATA[
String location = "template.ftl";
<set field="renderedText" from="ec.resource.template(emailTemplate.htmlLocation, '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.renderedText = sw.toString();
]]></script>
</actions>
<widgets>
......
......@@ -21,6 +21,9 @@ along with this software (see the LICENSE.md file). If not, see
<resource name="mjml">
<method type="get"><service name="mjml.MjmlServices.load#GrapeJs"/></method>
<method type="post"><service name="mjml.MjmlServices.store#GrapeJs"/></method>
<resource name="afterMjmlStore">
<method type="get"><service name="mjml.MjmlServices.get#AfterMjmlStore"/></method>
</resource>
</resource>
</resource>
......