Rock icon indicating copy to clipboard operation
Rock copied to clipboard

Merge Templates use wrong Lava RegEx

Open cabal95 opened this issue 7 years ago • 1 comments

Prerequisites

Description

When using Lava in a word merge template, if you try to use formatting like this:

{% for x in items %}{{ x.Name }}
{% endfor %}{% next %}

You will get a Lava error. Notice the line feed, it is intentional. We were trying to generate a name tag that has a list of strings, one per line underneath the name. This worked except for the last name tag on the sheet. Debugging I found that the XML parser was splitting the above into 2 XML nodes (because of the line break).

First node was {% for x in items %}{{ x.Name }}, second node was {% endfor %}{% next %}. When parsing the document the WordDocumentMergeTemplateType code looks for the last node with Lava and appends {% next %} if it is not contained in the node. Since the search is done for {{ }} style Lava, it finds the first node and appends {% next %} to it.

Later in the code the text is split by {% next %} and the lava is executed, causing a for tag not closed Lava error.

Current work around is to put {{ '' }} after the new line so it detects that node as Lava.

Steps to Reproduce

See above.

Expected behavior:

It should match the {% %} style Lava as well as {{ }}.

Actual behavior:

It doesn't. Current work around

Versions

  • Rock Version: 6.3
  • Client Culture Setting: en-US

cabal95 avatar Jun 26 '17 18:06 cabal95

I can confirm that this is still an issue in 2021 :) (version 12.3)

matthew-ewing avatar Jun 19 '21 20:06 matthew-ewing

After looking into this we don't see a way of supporting Lava that spans a Word document node. Perhaps in the future...?

jonedmiston avatar Sep 12 '23 20:09 jonedmiston