alonrbar/easy-template-x

parseTags does not show any errors

Opened this issue · 1 comments

I am using the parseTags method to extract all the tags and get any meaningful errors if there are any issues in the template file. However it seems to simply swallow any errors and not expose them.

I have a codesandbox link here that I have forked from the live demo: https://codesandbox.io/s/easy-template-x-demo-forked-9bxcox?file=/index.ts
The Get Tags button is what loads all the tags. The content of the docx file I'm using is as follows:

{name}
address}
some text
{phone_no

I expect it to throw the MissingStartDelimiterError for address} and MissingCloseDelimiterError for {phone_no
However it simple parses the name tag and returns that.

Some more context upon further investigation:

  • It does throw Can not join text nodes from separate paragraphs. error if two opening delimiters are in succession
  • We might be missing a case here where if the openedTag and openedDelimiter are not null we should throw an error for a missing close tag
  • The DelimiterSearcher#findDelimiters method does not take into account all the delimiters that are present. For example if your template only contains name}, the findDelimiters method returns an empty array