Reverse pystache

82 views Asked by At

I have this script:

import pystache
template = 'Hi {{person}}!'
data = {'person': 'Mom'}
txt = pystache.render(template, data)
print txt

Which gives:

Hi Mom!

Is there a way of doing something like:

data = reverse_pystache(txt, template)

So that a dictionary is returned:

>>> data
{'person': 'Mom'}

That is, reusing the template which was used to generate the text, and the actual text, extract the data from the text.

0

There are 0 answers