Is there a way to set a default value for an ${}
-style inline field in a Chameleon template so when it parse it does not die?
>>> from chameleon import PageTemplate
>>> template = PageTemplate("<div>Hello ${name}.</div>")
>>> template()
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/chameleon/utils.py", line 404, in __getitem__
return dict.__getitem__(self, key)
KeyError: 'name'
The documentation has some complex formats, but I cannot find this. But, given how obscure it is to figure that, say, ${structure: name}
does not escape html leaving it alone, I might have missed it.
The best I have come up with is a decorator for my Pyramid view functions under the view_config
decorator...