Announcement

Collapse
No announcement yet.

Storing the HTML used in a HTML Template in a file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.
Working...
X