either you put that function in models (works out of the box throughout all
the app), or you write the function in every view it's needed. For the
latter, please read
http://web2py.com/books/default/chapter/29/05/the-views#Functions-in-views
On Wednesday, April 23, 2014 10:19:55 PM UTC+2, Sharon Correll wrote:
>
> Is there any way to define your own helper-like function that will
> generate a bit of parameterized HTML? What I'd like to do is:
>
> <table>
> <tr>
> {{=TD_custom(data["field1"])}}
> {{=TD_custom(data["field2"])}}
> {{=TD_custom(data["field3"])}}
> {{=TD_custom(data["field4"])}}
> {{=TD_custom(data["field5"])}}
> {{=TD_custom(data["field6"])}}
> {{=TD_custom(data["field7"])}}
> ...
> <tr>
> <table>
>
> where the function is defined somewhere in my files:
>
> def TD_custom(string) :
> return TD(DIV(string, _class="custom", ...))
>
>
> Something that would allow me to avoid duplicating the detailed structure
> of the <td> for every field.
>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.