Massimo:

RE:  Style:  I completely agree w/ you about other templating
languages vs.  python-ic templates of web2py;

What I meant was that web2py offers filters, although maybe not of the
familiar shell form {{a|b|c}}, but rather {{c(b(a))}} --- THAT style,
I argued, is immaterial...

The other stuff (and more) I am with you on...  although there are
practical matters left to sort out (how true is this?) about how to
"plug-in" different layouts / styles...

Regards,
Yarko

On Oct 12, 6:44 pm, mdipierro <[EMAIL PROTECTED]> wrote:
> @pigmaj
> yes there should be more docs. For now this recipe is on AlterEgo and
> in the manual. I am looking into turning AlterEgo into a real wiki
> very soon.
>
> @yarko
> Yes this is mainly a stylistic difference but there are two practical
> differences:
>
> 1) in Django and Jinja you cannot use Python commands, only those
> defined/exposed by the template engine. This means if you need a
> filter you cannot define it in the view. My experience is that it
> takes some non-trivial work to define one.
>
> 2) in Django and Jinja I believe there is a logical issues with block.
> Consider this layout
> {{block a}}xxx{{endblock}}yyy{{block b}}zzz{{endblock}}
> and this view that extends it
> {{block a}}abc{{endblock}}efg{{block b}}hij{{endblock}}
> The output is: "abcyyyhij"
> What happens to "efg"? The template language allows you to write html
> that is never overwritten, is not a comment, yet it gets lost in the
> rendering. I think this is bad design.
> Am I wrong?
>
> Massimo
>
> On Oct 12, 6:03 pm, yarko <[EMAIL PROTECTED]> wrote:
>
> > Note - you can read all that wiki code in about maybe 3 minutes or
> > less ;-)
>
> > On Oct 12, 6:00 pm, pigmej <[EMAIL PROTECTED]> wrote:
>
> > > In Poland there is Monday 1 AM and... it's not sunny rotfl ;d
>
> > > On 13 Paź, 00:39, pigmej <[EMAIL PROTECTED]> wrote:
>
> > > > Thanks for naswers :)
>
> > > > In web2py I'm beginner. I generally don't like frameworks ( Django
> > > > etc ). I prefer using routers, werkzeug or paser and jinja2 for
> > > > templates, writing everything from scratch, etc. But for web2py I can
> > > > make exception. Let's see... ;)
>
> > > > On 13 Paź, 00:28, yarko <[EMAIL PROTECTED]> wrote:
>
> > > > > understood....
>
> > > > > I was arguing that having something like {{exterior_finish(car) }}
> > > > > is not any different than {{ car | pime | paint | bake | add_trim }}
> > > > > that is - where the code sits...
>
> > > > > But in the cases you meant, yes - {{my()}}  <static stuff>
> > > > > {{is_nicer_all_here()}}
>
> > > > > Thanks.
>
> > > > > As for multilne code:   write "normal" code, encapsulted in {{ }};
> > > > > for output, leave left side "blank" (dumps on template, so:
> > > > > {{=my_result(on_this)}}
> > > > > For starters, everywhere you would have "unindent" situation in
> > > > > python, in template put {{ pass }};
> > > > > Actually you only need where it would be ambiguous, but for starters,
> > > > > that's a good rule - after you have code working, try removing the
> > > > > "pass"s you think are not necessary.... won't take long to see where
> > > > > you don't need them.
>
> > > > > For HTML helpers, they take all (?) the (optional) parameters that the
> > > > > W3C defines for the HTML equivalents.
>
> > > > > For examples, get the appliances (e.g. KPAX, others on the "Repository
> > > > > of free apps" link at web2py.com)
>
> > > > > On Oct 12, 5:13 pm, pigmej <[EMAIL PROTECTED]> wrote:
>
> > > > > > Now I see that I can make with web2py templates almost everything 
> > > > > > :).
>
> > > > > > Massimo, I really think, You should add this recipes to howto :)
>
> > > > > > @yarko:
>
> > > > > > sometimes there is no staight way to modify something in controller.
> > > > > > But ok, I modify it, and then i loop them again in template -> so
> > > > > > there are two loops. One more than using filter in template ;)
>
> > > > > > How to write multiline python code in filter ?? I cannot find real
> > > > > > example for this momemt...
>
> > > > > > but maybe, replacing something in part of list/dictionary etc.
>
> > > > > > On 12 Paź, 23:49, yarko <[EMAIL PROTECTED]> wrote:
>
> > > > > > > This looks like only a stylistic discussion to me....
>
> > > > > > > Django has this too, and Jinja you say have a "shell like" syntax 
> > > > > > > of
> > > > > > > "pipes" --- that is output of one operation feeds input of 
> > > > > > > another.
> > > > > > > n
> > > > > > > {{ car | prime | paint }}   is equivalent to {{  
> > > > > > > paint(prime(car)) }},
> > > > > > > or for that matter {{ car.paint().prime() }}
>
> > > > > > > Functionally, I don't see anything you can do one way over the
> > > > > > > other..... it's a matter of style, convenience, what your used to,
> > > > > > > what you like reading.
>
> > > > > > > I like the "pipeline" syntax, but I learned on UNIX in the 
> > > > > > > mid-70's,
> > > > > > > so it's almost "genetic" for me to just read that.  The downside 
> > > > > > > to
> > > > > > > that is that you can get lulled into putting too much processing 
> > > > > > > in
> > > > > > > the template ... precisely because it's so readable.
>
> > > > > > > Having a utility function in a module, or a application local 
> > > > > > > function
> > > > > > > in a controller is - as you say - doable.
>
> > > > > > > But the more worthwhile thing is thinking about what you want to 
> > > > > > > do,
> > > > > > > and putting it in a good place.   And making the template as 
> > > > > > > concise
> > > > > > > as makes sense.
>
> > > > > > > re:  one loop more on contoller side - not sure I follow you on 
> > > > > > > that.
> > > > > > > Wherever you write the filters, they are running (in these 
> > > > > > > examples)
> > > > > > > on the server, applied similarly, and when they are done, the
> > > > > > > resulting output is rendered into something sent out over the
> > > > > > > network...  You could look at how many "calls" you have when 
> > > > > > > snippets
> > > > > > > are in the template vs. explicitly defined utility functions, but 
> > > > > > > I
> > > > > > > think this is more about the patterns of code maintenance (and
> > > > > > > reading) than anything...
>
> > > > > > > I think it probably would not be hard to apply a transform to
> > > > > > > templates so that you can pile up calls with the "pipeline" 
> > > > > > > flavor of
> > > > > > > showing transfer of control.   But, other than end user reading - 
> > > > > > > and
> > > > > > > what it might encourage about development steps - I don't think it
> > > > > > > materially changes anything.
>
> > > > > > > Am I missing something?
>
> > > > > > > Kind regards,
> > > > > > > Yarko
>
> > > > > > > On Oct 12, 4:30 pm, pigmej <[EMAIL PROTECTED]> wrote
>
> > > > > > > > massimo,
>
> > > > > > > > filters... ok but what if I need to make more operations with 
> > > > > > > > strings
> > > > > > > > etc, python operations, imports, parsing something ?
> > > > > > > > More lines of code.
>
> > > > > > > > For example I need to operate on dictionaries ( defining new, 
> > > > > > > > parsing
> > > > > > > > etc )
>
> > > > > > > > Theoretically, I can apply filters on controller side... but 
> > > > > > > > then
> > > > > > > > there is one ( or more ) loop more.
>
> > > > > > > > On 12 Paź, 23:01, mdipierro <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > > You can do both:
>
> > > > > > > > > 1) Example of passing variables to parent.
> > > > > > > > > Here is layout.html
>
> > > > > > > > >      
> > > > > > > > > <html><body><h1>{{=title}}</h1><p>{{include}}</p></body></html>
>
> > > > > > > > > and here is an example of index.html
>
> > > > > > > > >      {{title='something'}}
> > > > > > > > >      {{extend 'layout.html'}}
> > > > > > > > >      Hello World
>
> > > > > > > > > Also are variables returned by the action and defined in 
> > > > > > > > > models are
> > > > > > > > > also passed to the parent.
>
> > > > > > > > > 2) Example of a filter.
> > > > > > > > > You cannot filter HTML (because it does not make sense since 
> > > > > > > > > you write
> > > > > > > > > it) but you can filter TEXT (coming from a variable for 
> > > > > > > > > example) and
> > > > > > > > > the output of helpers. For example the following filter 
> > > > > > > > > replaces
> > > > > > > > > newlines with <br />, sanitize everything else and wraps 
> > > > > > > > > everything in
> > > > > > > > > a <p>.
>
> > > > > > > > >     {{def myfilter(s):}}
> > > > > > > > >         <p>{{=XML(str(s).replace('\n','<br 
> > > > > > > > > />),sanitize=False)}}</p>
> > > > > > > > >     {{return}}
>
> > > > > > > > >     {{=myfilter("""Any<span>html code that
> > > > > > > > >     you</span> like.""")
> > > > > > > > >     {{=myfilter(H1(SPAN('Hello\nWorld')))}}
>
> > > > > > > > > Massimo
>
> > > > > > > > > On Oct 12, 3:42 pm, pigmej <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > > > thanks for reply.
>
> > > > > > > > > > Python is templating engine - thats really good.
>
> > > > > > > > > > But I can only include file in one place and there is no 
> > > > > > > > > > way to change
> > > > > > > > > > anything in parrent file. That's a minus, and the minor 
> > > > > > > > > > problem for
> > > > > > > > > > mine.
>
> > > > > > > > > > The same thing with filters/macros. I need to use the same 
> > > > > > > > > > macro/
> > > > > > > > > > filter in many files. I cannot find this "option" in web2py
> > > > > > > > > > templates...
>
> > > > > > > > > > On 12 Paź, 22:11, yarko <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > > > > Also - if you want to use Genshi Templates (or try to do 
> > > > > > > > > > > something
> > > > > > > > > > > similar for Jinja2), see the Genshi4web2py.py  file and 
> > > > > > > > > > > instructions
> > > > > > > > > > > here:
>
> > > > > > > > > > >http://mdp.cti.depaul.edu/AlterEgo/default/show/162
>
> > > > > > > > > > > On Oct 12, 2:59 pm, yarko <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > > > > > There have been several discussions on this list on the 
> > > > > > > > > > > > topic -  for
> > > > > > > > > > > > example, look 
> > > > > > > > > > > > throughhttp://groups.google.com/group/web2py/browse_thread/thread/1ef4eea826...
>
> > > > > > > > > > > > I think a raesonable summary is:
>
> > > > > > > > > > > > -  web2py's templating, being very close to just being 
> > > > > > > > > > > > Python, is
> > > > > > > > > > > > likely to continue to be default for some time;
> > > > > > > > > > > > - some people have written tools to convert skins for 
> > > > > > > > > > > > other templates
> > > > > > > > > > > > to convert to web2py, so if it's available graphic 
> > > > > > > > > > > > designs you want,
> > > > > > > > > > > > that's one way to go
> > > > > > > > > > > > - there has been talk about still allowing an interface 
> > > > > > > > > > > > for other
> > > > > > > > > > > > engines.
>
> > > > > > > > > > > > I think interest (beyond one of discussion) has not 
> > > > > > > > > > > > been strong enough
> > > > > > > > > > > > for someone to identify all the core web2py things that 
> > > > > > > > > > > > would have to
> > > > > > > > > > > > be moved into a module, and rewritten for another 
> > > > > > > > > > > > template engine.
> > > > > > > > > > > > This has spurned talk and work about modules for 
> > > > > > > > > > > > web2py,  T2 being one
> > > > > > > > > > > > example.
>
> ...
>
> read more >>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
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