Is it possible to use Bottle's statement and functions from within a template?

20 views
Skip to first unread message

nikos.at....@gmail.com

unread,
Sep 26, 2018, 12:17:38 PM9/26/18
to bottlepy

I was wondering if i can use the static_file() from withing a template as follows:


{{ static_file( filename, root=filepath, download=True ) }}


Can it be written like that?

And if can, then how i will be able to substitite the variables within the statement, in my case, filename and filepath with their values taken from the wsgi python file?


And in general, are we able to use Bottle's framework statement and functions from within a template system or we can use then from the wsgi python app?!

Marcel Hellkamp

unread,
Sep 26, 2018, 12:30:50 PM9/26/18
to bott...@googlegroups.com
On 09/25/2018 10:11 PM, nikos.at....@gmail.com wrote:

I was wondering if i can use the static_file() from withing a template as follows:


No. Templates generate text. `static_file()` does not return text. Why should this work, and how?


And if can, then how i will be able to substitite the variables within the statement, in my case, filename and filepath with their values taken from the wsgi python file?


You are asking how to pass variables to a template? Please read the documentation. This is the most basic stuff there is about templates.

`bottle.template("template_name.tpl", varname=value)`

Reply all
Reply to author
Forward
0 new messages