Hi I am having problems with the template using Bottle
my folder structure is this:
|views
--main.tpl
--|blog
--home.tpl
what I want to do is this:
def home():
return template('blog/home')
but it won’t work
I can get it to work just calling the following:
def home():
return template('main')
But I want to be-able to have many different folders
I understand that I will still need to keep unique names because of the caching
and please don’t say use a different framework as this is not my choice.
You can try passing the template_lookup argument to the template function. template_lookup overrides the defaults .views path when looking for the template. However I believe this will only work if the name of the tempalte is not in the views folder. So if you had a /views/main.tpl and a /blog/main.tpl it would not work, every template needs a unique name. This is needed because bottle will only lookup search for tempaltes if it hasn’t found it before and stores the found ones in a dict with the tempalte name as the key. so if the templates have the same name it would use the first one.