Building a tag that does not render but needs to do something #719
Unanswered
wturnerharris
asked this question in
Q&A
Replies: 1 comment
-
I think you should remove the line with “ this.stream.on”, it’s used to parse children templates and the debug tag has no children. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey @harttle - I was working on a tag to support a custom tag, and I'm running into a ParseError.
Here's the very basic filter:
The liquid code is also simple, and works as expected with this filter:
However when a condition wraps this "function" it doesn't work and breaks:
And the error looks like this:
Intent and Progress:
This debug function should be simple—take the variable in the tag and output it in console or a log file. That's working as expected. However, because there's no "end tag" it seems like context of the tag is getting confused. If I remove the
if
condition or put the condition somewhere else, the tag works perfectly. If I remove thestream
from starting, then it also doesn't throw an error, but the render function never runs. Ultimately nothing needs to render with this function, but something needs to happen, and it needs to be inside of a condition.I was reviewing the "assign" tag from source and really tried replicating a similar definition because there is no end tag as well. I keep running into this parse error where "endif" is not found, but it's clearly there. So my assumption is that the parser is getting confused and not closing out properly. My assumption was that if I
.stop()
the stream it would signal the tag is closed. Is there something else I need to call to close it out?Beta Was this translation helpful? Give feedback.
All reactions