Hi Zak, i wouldn't discount Justins global reply - i use that one often, and
it is very nice (especially if you need to use libraries inside an entire
site)! :)

On Fri, Aug 13, 2010 at 3:21 PM, Zak <[email protected]> wrote:

> Christophe,
> Thanks. Your discussion is great.
> I should move that regexp part to model, then in control call that
> regexp function, pass the return to render, instead of doing the
> working in template.
> Zak
> On Aug 12, 4:33 pm, zbouboutchi <[email protected]> wrote:
> >   Hi Zak,
> >
> > In this case, why wouldn't you send a tuple bar = ('foo', '2') to
> > template  using a regexp in controller and using bar[0] ( 'foo' ) and/or
> > bar[1] ('2'), even ''.join(bar) ('foo2') in you template ?
> > Maybe I didn't understand what you want to do... But in most case, I
> > imagine templates using python to organize and manage the page
> > structure, under the conditions required by the data provided in the
> > render call, but not to manage data itself or make some calculus on it.
> > You'll always find a solution to manage to do that. This limit is easy
> > to remember and you can ask yourself if an operation must be done in the
> > python class or in the template.
> > The benefits of this method is to understand immediately when you face a
> > strange bug if you must seek and destroy it in the template or in the
> > controller ..
> >
> > A small reminder on the way to send data in a template, if you care ;).
> > To send any data to a template, you can do something like this:
> >      render.my_template(session, my_data=['tagada','tsouin'],
> > my_dict={'blibli': 5, 'blublu': 7}).
> > This way, you can use all the data you send with exactly the same data
> > structure.
> > This way, you're able to use session directly in the template, or access
> > my_data[1], or my_dict['blibli'] in you template.
> > This enable you the possibility to manage the data in any ways you want
> > and send exactly what you need in the template before processing it.
> >
> > The only reason that would make me include some calculus in templates
> > would be an external event during rendering that needs a different
> > rendering than it would be before the render call in the python
> > function. In web.py, when you return render.*, alea jacta est ;).
> >
> > Regards,
> >
> > Christophe.
> >
> > On 08/12/2010 07:04 PM, Zak wrote:
> >
> > > Yes, the case is kind of odd/weird.
> > > Suppose I get a return Foo<sub>2</sub>  from Control/Model, then I do a
> > > search of Foo2 instead of Foo<sub>2</sub>, but I also need display the
> > > original one. For example, on displaying page, I need add link on the
> > > returns,  which are displayed as it is get from database, links are.
> > > Given the return is 'Foo<sub>2</sub>', I want:
> > > <a href='www.foo.com/?name=Foo)>Foo<sub>2</sub></a>
> > > I think one of solution may be,
> > > <a href='www.foo.com/?name=$:re.sub(r'</?sub>','', 'Foo<sub>2</
> > > sub>')>Foo<sub>2</sub></a>
> > > I wish my poor English describe the case. Is there an alternative good
> > > way to do the work?
> > > Thanks for your all help.
> >
> > > On Aug 11, 11:57 pm, zbouboutchi<[email protected]>  wrote:
> > >>    Hi Zak,
> >
> > >> I don't know why you want to do this substitution during rendering, it
> > >> seems to me a little odd, but possible ..
> > >> Indeed I'm curious to see why you want to process things like this,
> > >> could you explain your idea ?
> >
> > >> Thanks ;)
> >
> > >> On 08/11/2010 10:52 PM, Zak wrote:
> >
> > >>> Hi All,
> > >>> I have a quick question. Is it possible using re.sub (python module
> > >>> re) in template files? I want to do some substitution dynamically
> > >>> during rendering.
> > >>> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "web.py" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected] <webpy%[email protected]>.
> For more options, visit this group at
> http://groups.google.com/group/webpy?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" 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/webpy?hl=en.

Reply via email to