librelist archives

« back to archive

widgets

widgets

From:
Alessio Civitillo
Date:
2011-08-17 @ 18:44
Hello,

I would like to create widgets (chart, tables, etc.) to insert in different
templates. I think this is not possible with the render_template method?
Also, the widgets need to get data.

Thanks
alessio

Re: [flask] widgets

From:
Maxim Chervonny
Date:
2011-08-18 @ 09:32
Since there is no answer, I'll try (but i'm nube).

I think you should write something like this in your app:

@app.route('/page1')
def index():
     widget1 = "Hello"
     widget2 = "World"
     return render_template('index.html', widget1=widget1, widget2=widget2)

@app.route('/page2')
def index():
     widget1 = "Hello"
     # the same template, but another variables passed to it
     return render_template('index.html', widget1=widget1)

And then in template, you should check if widget 1 or 2 exists:

{% if widget1 %}
     {{ widget1 }}
{% endif %}

{% if widget2 %}
     {{ widget2 }}
{% endif %}


On 8/17/11 10:44 PM, Alessio Civitillo wrote:
> Hello,
>
> I would like to create widgets (chart, tables, etc.) to insert in different
> templates. I think this is not possible with the render_template method?
> Also, the widgets need to get data.
>
> Thanks
> alessio
>

Re: widgets

From:
Alessio Civitillo
Date:
2011-08-18 @ 09:05
Not sure if this reached the mailing list.

On Wed, Aug 17, 2011 at 8:44 PM, Alessio Civitillo <
alessiocivitillo@gmail.com> wrote:

> Hello,
>
> I would like to create widgets (chart, tables, etc.) to insert in different
> templates. I think this is not possible with the render_template method?
> Also, the widgets need to get data.
>
> Thanks
> alessio
>



-- 
Regards,
------------------------------------
Alessio Civitillo
alessiocivitillo@gmail.com
Mobile: (0045) 52645608
Linkedin: http://it.linkedin.com/in/alessiocivitillo

Re: [flask] Re: widgets

From:
Daniele Nicolodi
Date:
2011-08-18 @ 09:37
On 18/08/11 11:05, Alessio Civitillo wrote:
>> On Wed, Aug 17, 2011 at 8:44 PM, Alessio Civitillo 
<alessiocivitillo@gmail.com> wrote:
>> 
>>     Hello,
>> 
>>     I would like to create widgets (chart, tables, etc.) to insert in
>>     different templates. I think this is not possible with the
>>     render_template method? Also, the widgets need to get data.
>
> Not sure if this reached the mailing list.

It did, but in your email you did not formulate a question, so it is
rather unlikely that it will receive an answer.  That said, the default
template engine used in Flask is Jinja2, which has also excellent
documentation: http://jinja.pocoo.org/docs/

PS: correct email quoting is performed when the thread history flows
from top to bottom, the natural direction for reading, like above.

Cheers,
-- 
Daniele