Hi Antony, Thanks. I am experimenting with the Massimo idea of a bottle
based framework using web2py components, And I was looking if there was
an equivalent of the jinja2 "Environment.globals". The code is in
https://github.com/daxslab/ron
Greetings.
El 28/1/19 a las 8:16 a.m., Anthony escribió:
Can you show some code or describe in more detail what you are trying
to do?
If you are using the render() function from gluon.template, note that
it takes a context argument, which is a dictionary used to generate an
execution environment. You can do:
|
ENV ={
'var1':'value 1',
'var2':'value 2'
}
output =render(filename='mytemplate.html',context=ENV)
|
In the template, you can then reference var1 and var2 (e.g., {{=var1}}).
If you want to create an environment similar to the web2py
environment, have a look
at https://github.com/web2py/web2py/blob/cef31f127796c638753297235f4e886f6a9e5410/gluon/compileapp.py#L387-L450
to see how web2py sets up its environment.
Anthony
On Wednesday, January 23, 2019 at 8:09:34 AM UTC-5, Carlos Cesar
Caballero wrote:
Hi guys, I am using the web2py templates in a side project and I
want to
include some variables in the environment by default, something
like how
helpers, request and response are included in the framework, but I
can't
find how this is done. Any idea?
Greetings.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google
Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to web2py+unsubscr...@googlegroups.com
<mailto:web2py+unsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.