bottlepy / bottle

bottle.py is a fast and simple micro-framework for python web-applications.
http://bottlepy.org/
MIT License
8.34k stars 1.46k forks source link

Specialised template loaders have no knowledge of the extension commonly associated with their engine #1259

Open lenormf opened 3 years ago

lenormf commented 3 years ago

Hi,

When using for example @mako_view("index"), the template engine will not pick up index.mako.

This happens because the BaseTemplate class has a hardcoded list of extensions that its specialisations don't modify accordingly to the extension that is commonly associated with them.

I'm currently working around that issue with the following:

bottle.BaseTemplate.extensions.append("mako")

I think a better way would be for the MakoTemplate, CheetahTemplate and Jinja2Template to pass to their parent class an additional extension upon instantiation. Consequently, the stpl extension should not be kept as a default extension in BaseTemplate, but passed by the SimpleTemplate class.

I can do a PR if you want me to!

HTH.

lenormf commented 3 years ago

Ping