web stats
Storing the HTML used in a HTML Template in a file - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 04-08-2017, 07:48 PM
Geoff Wass Geoff Wass is offline
What's HL7?
 
Join Date: Mar 2017
Posts: 2
Geoff Wass is on a distinguished road
Default Storing the HTML used in a HTML Template in a file

I am new to Mirth Connect and this is my first post. I have searched and not found anything that relates to what I am trying to do. I am using Mirth Connect 3.4.2.8129 on Windows 10.

I have a test channel which polls a Windows folder and reads from text files which each contain a single HL7 message. There is a Destination Connector which has a Document Writer set to produce RTF documents.

When the HTML Template field of the Destination Connector contains the following HTML, it works correctly:

<html>
<body>
<h1>My Report Title</h1>
<h2 style="color: #990000;">${MyVar1}</h2>
<h3>Second value: ${MyVar2}</h3>
</body>
</html>

It produces output like this, as expected:

My Report Title
My Value 1
Second value: My Variable Two


However, I would like to read the HTML from a file and place it into the HTML Template field. The idea is to have one HTML template which can be used by several destination connectors.

I have set up some Global Script code to read in the HTML to a string variable:

var simpleTemplate = FileUtil.read('C:\\Mirth Work\\Templates\\SimpleRTFTemplate.html');

globalMap.put('SimpleRTFTemplate',simpleTemplate);


I have created a Transformer Step which creates a channel variable SimpleRTFText like this:

globalMap.get('SimpleTemplate')

I have then dragged the channel variable into the HTML Template field to replace the HTML text I had before:

${SimpleRTFTemplate}

This will produce an RTF. Unfortunately, it does not evaluate the velocity variables in the string and simply creates an RTF that literally looks like the text read from the HTML file:

My Report Title
${MyVar1}
Second value: ${MyVar2}


So my question is: How do I get the connector to evaluate the velocity variables within the HTML text string before it creates the RTF?

It feels like the velocity command #include <myfile> would be cleanest the thing to use, but that does not work. Perhaps there is something besides ${SimpleRTFTemplate} which could be used which force the text to be both inserted and evaluated.


PS. I do realize that there is a known issue with the conversion and that leading white space is being picked up and included in the output. That is another reason I want to put the HTML in a separate file so that it can be minified first.
Reply With Quote
Reply

Tags
html template, rtf, velocity variables

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 08:42 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation