Because you can do stuff like this:

rows = db(...#get some arbitrary rows
tbody = TBODY()
for r in rows:
  tbody.append(TR(...# do complex stuff with row data.  If a list of rental 
properties, for example, style the address red if vacant
table=TABLE(THEAD(...arbitrary column headings), tbody)

The ability to manipulate the DOM like this helps separate page design from 
content.  This is a good thing, even if you are a solo developer.

On Thursday, September 6, 2012 1:30:03 AM UTC-4, luckysmack wrote:
>
> Traditionally, for html templates, I would do something like this in a 
> template.php file (i am coming from php):
>
> *<div>*
> *    Hello <?= $name ?>*
> *</div>*
>
> and reading through the docs for web2py, I see the classes like DIV(), 
> which i can then add id's, classes, and other attributes to, to be 
> rendered. Which seems odd to me. Ive always had the mindset that I shouldnt 
> mix html template and logic. minus things like for loops and such. and in 
> my code, I shouldnt generate html. Mixing them, to me at least, makes it 
> harder for designers to go into the templates to style things and change 
> id's, classes. I also tend not to use ids/classes for structure. lately i 
> have been using things like data attributes to help with structure or 
> looping through things. this way if styles change and id's/classes change, 
> functionality is not broken.
>
> So should I still think that way? Should I not use DIV and the other html 
> helper classes in my templates? or is there a use case where I would to 
> that.
>
> If there is, I am curious to see/hear about some use cases or examples of 
> why I would use them in templates, or use them in controllers to generate 
> html.
>
> or am I just thinking about them wrong somehow. if they should be used in 
> a different way, how should I use them.
>
> Thanks.
>

-- 



Reply via email to