As others have already stated. This PHP
*<div>*
* Hello <?= $name ?>*
*</div>*
translates in this web2py:
*<div>*
* Hello {{= name }}*
*</div>*
You use helpers when html must be geneted programmatically to avoid
concatenating strings which can cause XSS vulnerabilities. For example:
{{=SELECT(*[OPTION(option) for option in options])}}
On Thursday, 6 September 2012 00:30:03 UTC-5, 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.
>
--