Closed spra85 closed 5 years ago
@spra85 I just happened to be looking for this, and there is a tokenizer function you can use:
from chevron.tokenizer import tokenize
It returns a generator of (token_type, content)
tuples.
@johnfraney, somehow I missed this when you initially responded, but thanks for sending. Will definitely take a look.
@johnfraney, I actually ended up just writing my own custom regex for this. Basically,
import re
sorted({k for k in re.findall(r"{{\^?#?\/?{?(\w+)}}}?", template_content)})
We use Pystache's
parse
method so we know what variables/conditionals/etc. are in a given template. I'm curious if there's been any thought to supporting something like that in Chevon? Through perusing the source code, I didn't see anything like that available but not mentioned in the README but I may have missed it.