f0694f89 by acetousk

Fix formatting issue

1 parent 7e2aa82e
......@@ -24,6 +24,40 @@ along with this software (see the LICENSE.md file). If not, see
<if condition="dataPre == null">
<return error="true" message="Email Template does not exist at ${emailTemplate.htmlLocation} with version ${emailTemplate.htmlPublishedVersionName}"/>
</if>
<set field="doc" from="org.jsoup.Jsoup.parse(dataPre)"/>
<script><![CDATA[
doc.outputSettings().escapeMode(org.jsoup.nodes.Entities.EscapeMode.xhtml).prettyPrint(false);
doc.traverse(new org.jsoup.select.NodeVisitor() {
public void head(org.jsoup.nodes.Node node, int depth) {
if (node instanceof org.jsoup.nodes.TextNode) {
def text = node.getWholeText();
if(text.trim().length() > 0) {
def newText = "";
def lines = text.split("\n");
for (line in lines) {
if (line.startsWith("<br>")) {
line = line.replaceFirst(/^<br>/, "");
}
if (line.endsWith("<br>")) {
newText += line;
} else {
newText += line + "<br>";
}
}
if (newText.startsWith("<br>")) {
newText = newText.replaceFirst(/^<br>/, "");
}
node = org.jsoup.nodes.TextNode.createFromEncoded(newText);
}
}
}
public void tail(org.jsoup.nodes.Node node, int depth) {
// No action needed on tail
}
});
]]></script>
<set field="dataPre" from="doc.html()"/>
<script><![CDATA[
String location = emailTemplate?.htmlLocation ?: "template.ftl";
......
......@@ -385,13 +385,15 @@ along with this software (see the LICENSE.md file). If not, see
<entity-find-one entity-name="moqui.resource.DbResourceFileHistory" value-field="usedResourceHistory" auto-field-map="[resourceId:resource.resourceId,previousVersionName:resourceHistory.versionName]" for-update="true">
<select-field field-name="resourceId,versionName,versionDate,previousVersionName,userId"/></entity-find-one>
<!-- <log level="warn" message="set versionName ${usedResourceHistory.versionName} of previousVersionName ${usedResourceHistory.previousVersionName} to ${resourceHistory.previousVersionName}"/>-->
<set field="usedResourceHistory.previousVersionName" from="resourceHistory.previousVersionName"/>
<if condition="usedResourceHistory">
<set field="usedResourceHistory.previousVersionName" from="resourceHistory?.previousVersionName"/>
<log level="info" message="Removed resource history ${resourceHistory.resourceId} version ${resourceHistory.versionName}"/>
<set field="removedHistoryList" from="removedHistoryList + [resourceId:resource.resourceId, versionName:resourceHistory.versionName,versionDate:resourceHistory.versionDate,userId:resourceHistory.userId]"/>
<entity-update value-field="usedResourceHistory"/>
<entity-delete value-field="resourceHistory"/>
</if>
</iterate>
</iterate>
......