jinja_partials
jinja_partials copied to clipboard
Bottlepy
Is there scope to get this working on bottlepy? My normal stack jinja2 templating in Bottle. I'm half way through the htmx course which is pretty neat and wanted to see if I could get this to work. Cheers
Hi @benboughton1 I think you could definitely make this happen. You just have to slightly tweak how you initialize the jinja engine and you'd be good to go, from this SO answer:
Two options:
# At startup:
from bottle import BaseTemplate
BaseTemplate.defaults['myglobal'] = 'My global'
# As a request wrapper:
from bottle import Jinja2Template
@hook('before_request')
def before_request():
Jinja2Template.defaults['myglobal'] = 'My global'
You know Bottle better than me, would this work?
Maybe I could write a register bottle version of this:
https://github.com/mikeckennedy/jinja_partials/blob/31e813008dc60d1e8c0e7c2ad0fb6045ae54009a/jinja_partials/init.py#L58
What do you think?
Closing this since I think it's gone stale and my recommendation above could fix it. Please let me know if anyone wants me to reopen it.