If it is fixed content, use the second pattern (though note that in HTML, 
you do not enclose text in quotes as you have). If you need to generate the 
content dynamically, just pass the data from the controller to the view, 
build the HTML structure in the view, and insert the data where needed. For 
some tips on using the HTML helpers vs. raw HTML in the views, see 
http://stackoverflow.com/questions/8091487/what-are-the-benefits-of-building-html-markup-with-html-helpers-in-web2py/8095585#8095585.

Anthony

On Sunday, June 21, 2015 at 12:13:03 PM UTC-4, anonymous anonymous wrote:
>
> Dear all,
>
> this is my first post as well as my first attempt with web2py. I've read 
> through most of the book and have the following question.
>
> Here are a few guidelines I've understood:
>
>
>    - Each controller/function should have it's own view
>    - There are two ways to build up a webpage one is programmatically and 
>    one is by modifying the view.
>
> For example I could have a view:
>
>
> # controller.py
>
>
> def fun1():
>
>     return { 'content' : H1('Hello') + P('this is my first app World') }
>
>
> def fun2():
>
>     return { 'content' : H1('Hello Again') + P('this is the second page') }
>
>
> and 
>
>
> views/controller/fun1.html
>
>
> {{extend layout.html}}
>
> {{=content}}
>
>
> views/controller/fun2.html
>
>
> {{extend layout.html}}
>
> {{=content}}
>
>
> The alternative would be:
>
>
> # controller.py
>
>
> def fun1():
>
>     return { }
>
>
> def fun2():
>
>     return { }
>
>
> and views:
>
>
> views/controller/fun1.html
>
>
> {{extend layout.html}}
>
> <h1>'Hello'</h1>
>
> <p>'this is my first app World'</p>
>
>
> views/controller/fun2.html
>
>
> {{extend layout.html}}
>
> <h1>'Hello Again'</h1>
>
> <p>'this is the second page'</p>
>
>
> What is the difference, which is better practice? In this simple case 
> which pattern is it advisable I follow?
>
>
> Thank you
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to