ruby-docx-templater icon indicating copy to clipboard operation
ruby-docx-templater copied to clipboard

Unmatched Template Error

Open bkarst opened this issue 11 years ago • 5 comments

<w:p>
  <w:pPr>
    <w:pStyle w:val="Body 2"/>
    <w:bidi w:val="0"/>
  </w:pPr>
  <w:r>
    <w:t>#BEGIN_ROW:EXPERIENCES_TITLE#</w:t>
  </w:r>
</w:p>
<w:p>
  <w:pPr>
    <w:pStyle w:val="Heading"/>
    <w:bidi w:val="0"/>
  </w:pPr>
  <w:r>
    <w:rPr>
      <w:rFonts w:ascii="Didot" w:cs="Arial Unicode MS" w:hAnsi="Arial Unicode MS" w:eastAsia="Arial Unicode MS"/>
      <w:rtl w:val="0"/>
    </w:rPr>
    <w:t>$EACH:EXPERIENCE_TITLE$</w:t>
  </w:r>
</w:p>
<w:p>
  <w:pPr>
    <w:pStyle w:val="Body 2"/>
    <w:bidi w:val="0"/>
  </w:pPr>
  <w:r>
    <w:t>#END_ROW:EXPERIENCES_TITLE#</w:t>
  </w:r>
</w:p>

I'm zipping the following xml into a docx template. (I'm not posting the entire xml doc)

And I'm inserting the following data into the template: {'experiences_title' => [{'experience_title' => "Experience"}}

It doesn't seem to recognize any of my row markers. When I try to generate the doc, I'm getting:

unmatched template markers: #BEGIN_ROW:EXPERIENCES_TITLE# nil: true, #END_ROW:EXPERIENCES_TITLE# nil: true. This could be because word broke up tags with it's own xml entries. See README.

bkarst avatar Apr 20 '14 00:04 bkarst

I'm also getting this error. Is there a fix for this?

elliotwesoff avatar Oct 07 '15 00:10 elliotwesoff

I'm also getting the same error. Is it mandatory to loop inside the table? When I'm looping inside the table, it works fine but when I do the looping(#BEGIN_ROW:XXX# and #END_ROW:XXX#) without table, I'm getting the above error.

rubymaniac2012 avatar Jul 14 '16 07:07 rubymaniac2012

@nav0285 I came up with a fix for this. It causes the build to fail but it works for what I needed it to do. https://github.com/jawspeak/ruby-docx-templater/pull/13

elliotwesoff avatar Jul 14 '16 16:07 elliotwesoff

@nav0285,

My last comment has a link to the pull request, in which you can see the code changes. The author has a "fail" statement when the array markers are unmatched. I changed it so that rather than failing and raising error, it just returns the XML at that point in the method.

elliotwesoff avatar Jul 14 '16 18:07 elliotwesoff

Happy to merge #13 if the tests are passing. ok to change the tests too based on this new behavior.

jawspeak avatar Jul 18 '16 22:07 jawspeak