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

Go Back   Mirth Community > Mirth Connect > Support

Thread Tools Display Modes
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 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:

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

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');


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


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


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
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

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 11:25 PM.

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