Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parseTags does not show any errors #90

Open
sj-1010 opened this issue May 4, 2023 · 2 comments
Open

parseTags does not show any errors #90

sj-1010 opened this issue May 4, 2023 · 2 comments
Labels
feature request New feature or request

Comments

@sj-1010
Copy link

sj-1010 commented May 4, 2023

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.

@sj-1010
Copy link
Author

sj-1010 commented May 4, 2023

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

@alonrbar
Copy link
Owner

alonrbar commented Jan 27, 2025

Hi, thank you for reporting this.

I've looked at this issue in the past and unfortunately it's not trivial to throw such errors from the TagParser code. However, the solution I'm currently using in my apps is going over the output of parseTags and running additional validation logic on that. Perhaps I can incorporate this logic into parseTags... For now I'm treating this part as a feature request but not sure when I'll get to it (as said, the workaround for now is to do basic validation on the function output).

Having said that, the Can not join text nodes from separate paragraphs. error should be a strongly typed error with some informative message and I'll try to fix that soon.

@alonrbar alonrbar added feature request New feature or request and removed feature request New feature or request labels Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants