Using SimpleTemplate in Bottle

bottle, template-engine

Solution

Here's a nice, simple solution in the spirit of your original question:

tpl = SimpleTemplate(name='views/index.tpl')  # note the change here

@app.get('/')
def index():
    return tpl.render()

Problem

I'm new in Frameworks like Bottle and working through the Documentation/Tutorial. Now I got a Problem with the Template-Engine: I have a file called `index.tpl` in my folder `views`. (it's plain html) When I use the following Code, it works to display my html: ``` from bottle import Bottle, SimpleTemplate, run, template app = Bottle() @app.get('/') def index(): return template('index') run(app, debug=True) ``` Now I want to implement this engine in my project and dont want to use `template()` I want to use it as it stands in the documentation, like: ``` tpl = SimpleTemplate('index') @app.get('/') def index(): return tpl.render() ``` But if I do so, the Browser shows me just a white page with the word index written, instead of loading the template. In the documentation, there is no further information on how I use this OO approach. I just couldn't figure out why this happens and how I have to do it right...

Original source