On Wednesday, November 11, 2015 at 9:10:11 AM UTC-8, Anthony wrote:
>
> with open(os.path.join(request.folder, 'static',"words", "words.txt"),
> 'r') as infile:
> content = CAT()
> for line in infile:
> s = SPAN(line, _class="body")
> content += P(s)
>
> The CAT() helper is for concatenating other helpers without wrapping them
> in an HTML tag when serialized.
>
It has become *my* favorite helper.
>
> More simply:
>
> with open(os.path.join(request.folder, 'static',"words", "words.txt"),
> 'r') as infile:
> content = CAT(*(P(SPAN(line, _class='body')) for line in infile))
>
> Anthony
>
>
/dps
> On Wednesday, November 11, 2015 at 9:51:48 AM UTC-5, Brendan wrote:
> I would like to programmatically take text files in the controller, format
> them (per paragraph with spans and p) and pass them to a view as
> {{=content}}.
> The helpers seem to be designed to prevent me from doing that (eg can't
> accumulate them one at a time into the string content).
> response.write puts them in the wrong place.
> SPAN(text).xml() gets escaped.
>
> For example (in controller/default.py):
>
> def words():
>
> with open(os.path.join(request.folder, 'static',"words",
> "words.txt"),'r') as infile:
> content = ""
> for line in infile:
> s = SPAN(line, _class="body")
> content +=P(s) # I know this doesn't work
>
>
> return dict(content=content)
>
>
> How do I go about achieving this?
>
> Thanks
>
>
> Brendan
>
>>
>>
>>
--
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.