I cannot find a function to set the locals for processing jade. I'm attaching the workaround I'm using for now below (a little test included), but I'm surprised that this does not seem to be in the API out of the box, so I'm reporting this as a missing feature.
import pyjade
from pyjade.ext.html import HTMLCompiler
def process_jade(src, data={}):
parser = pyjade.parser.Parser(src)
block = parser.parse()
compiler = HTMLCompiler(block, pretty=True)
compiler.global_context.update(data)
return compiler.compile()
print(process_jade("""
!!! 5
html
body
ul
each val in my_list
li= val
""", dict(my_list=[1, 2, 3])))
I cannot find a function to set the locals for processing jade. I'm attaching the workaround I'm using for now below (a little test included), but I'm surprised that this does not seem to be in the API out of the box, so I'm reporting this as a missing feature.
Thanks!