[Flask] Jijna2 default templates

Alejo Arias alejoar at gmail.com
Thu Apr 14 07:58:46 EDT 2016


Hi Satya,

It is quite easy. Here is a quick example for what you mentioned.

If you have an array in flask with an undetermined number of options that
you want to use in your dropdown:

my_options = ['option1', 'option2', 'option3', 'option4']


You can generate your html dropdown in Jinja like this:

<select>
>     {% for option_name in my_options %}
>     <option>{{option_name}}</option>
>     {% endfor %}
> </select>


In my opinion, I think it is not difficult to learn Jinja and it integrates
well if you are also learning Flask at the same time.

Regards,
Alejo


On 14 April 2016 at 13:42, Satya Elipe <satya.elipe at gmail.com> wrote:

> Hi Alejo
>
> Thanks for the prompt response and for the useful info.
>
> Got it. So if I want to build up a web app (mostly for static info, with
> drop down boxes), how easy or difficult it is to use jinja ?
>
> In general how easy it is to learn jinja for a new comer like me in web
> development (I heard jinja is powerful with its powerful library and
> inheritance, hence through of picking it up for my career on web
> development).
>
> Kindly advise.
>
> Sure, will take a look at below pointers.
>
> Thanks
> Satya
>
>
>
> On Thursday, 14 April 2016, Alejo Arias <alejoar at gmail.com> wrote:
>
>> Hello Satya,
>>
>> Jinja is a templating language and there are no "default" templates as
>> far as I know. It is like asking for a "default" flask application. I guess
>> what you are really asking for might be a "hello world" flask application
>> that uses Jinja.
>>
>> There are several guides to learn how to use Jinja with examples that you
>> can find googling a bit. Here's one:
>> https://realpython.com/blog/python/primer-on-jinja-templating/
>>
>> In that tutorial they use Bootstrap with Jinja, which might be closer to
>> what you were looking for if you assume Bootstrap as a default template.
>>
>> Miguel Gringberg's flask book also guides you through using Jinja with
>> bootstrap, I recommend reading it.
>>
>> Hope that helps.
>>
>> Regards,
>> Alejo
>>
>>
>> On 14 April 2016 at 12:41, Satya Elipe <satya.elipe at gmail.com> wrote:
>>
>>> Hello
>>>
>>> I'm new to flask web development.
>>>
>>> Just wondering if there's any default templates available in ninja2 that
>>> I can just import and use ?
>>>
>>> Also would be great if some one comment on the best way to use those
>>> default templates.
>>>
>>> Just want to give it a try with default templates rather than start
>>> creating my own to begin with.
>>>
>>> Thanks in anticipation
>>> Satya
>>>
>>> _______________________________________________
>>> Flask mailing list
>>> Flask at python.org
>>> https://mail.python.org/mailman/listinfo/flask
>>>
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20160414/6ebca9d3/attachment-0001.html>


More information about the Flask mailing list