Reputation: 120709
I have a custom liquid tag. Inside of this tag, I'd like to know the specific line number and character position of the tag itself, in the original template file.
I see that a tag has access to the tokens from the constructor. The tokens is an array of lines that follow the closing tag in the file. This is interesting, but not what I'm looking for.
Any ideas or tips?
Thanks!
Upvotes: 0
Views: 67
Reputation: 61
You didn't say which parser you are using, but the first step in the official parser is to tokenize the entire template to an array of strings1, losing file coordinates in the process. So I think you (and I) are out of luck without revamping the parser.
1 https://github.com/Shopify/liquid/blob/master/lib/liquid/template.rb#L166
Upvotes: 1