Yes not very pythonic. I think the web2py way is more pythonic

blocks in layout.html:
{{myblockcode1()}} {{myblockcode2()}}
and in index.html:
{{def myblockcode1():}}<h1>Hello</h2>{{return}}
{{def myblockcode2():}}<h2>World</h2>{{return}}
{{extend 'layout.html'}}

escaping a string is the default
{{="some string"}}
or
{{=apply_filter("some string")}}

loops:
{{for  x in xrange(20):}}
  do whatever you want
{{pass}}

"pass" is a python keyword, "endfor" is not and it could not even be
defined within python. It seems to me jinja is reinventing the wheel
(for the second time, since Django reinvented it first).

Massimo

On Oct 12, 4:20 pm, pigmej <[EMAIL PROTECTED]> wrote:
> sure,
>
> for example in base template I define "block", then in child template
> I can modify content of this block, that's useful in many,many
> situations.
>
> Secondly. Custom filters. I write python function in any file, then I
> add it to jinja env and after that I can use it as a normal filter in
> template.
>
> Jinja syntax is very clean and easy ( it's similar to web2py & django
> too ).
>
> Examples in jinja:
>
> escaping a string:
> {{some_string|e}}
> applying filter:
> {{some_string|some_filter}}
>
> loops:
> {%for x in xrange(20)%}
> (...)
> {%endfor%}
>
> as you see its really easy ( web2py is really easy too )
>
> The blocks and easy to write and use filters are a BIG advantages of
> Jinja. Other things are easy to "translate" to web2py templates, I
> think.
>
> Naturally I'm describing only basics of templates
>
> On 12 Paź, 22:37, mdipierro <[EMAIL PROTECTED]> wrote:
>
> > Yes you can as Yarko explains but:
>
> > 1) your app will not be portable, since it will require the other
> > engine installed
> > 2) You lose the ability to byte-code compile templates and distribute
> > them in a closed-source web2py app.
> > 3) The current web2py template engine, because of bytecode compilation
> > and one-time parsing using only regex is faster than alternatives.
> > 4) I will argue that other engines do not have "more features" only
> > "more syntax to learn"
> > (unless you consider a feature limiting what template designers can
> > do).
>
> > Anyway, I may be wrong about 4 and I do like Genshi for example, but I
> > fail to see the point of Jinja.
> > Could you tell what you like about it and why you consider it superior
> > to the default web2py one?
>
> > Massimo
>
> > On Oct 12, 2:27 pm, pigmej <[EMAIL PROTECTED]> wrote:
>
> > > Is there any way to change default template engine in web2py?
>
> > > I would like to change it to something better with more features like
> > > Jinja2
>
> > > Or maybe there is a lot of undocumented things in default template
> > > engine ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to