Manish Sivanandan
Manish Sivanandan

Reputation: 83

Including part of html file in web2py

I am a newbie to web2py and want to do this.. I am doing a presentation web application , in which users can view presentations(reveal.js files) of a number of topics. These presentations contain head tags and scripts which are same to all.. so i thought of creating a view called default/presentation.html and then store all the presentations as html/xml files and display them inside the learn.html file (these files contain only part of file, stuff within the body tag). But I have tried a lot of stuff, but still could not get id due to web2py's default escaping feature. Please help me out with the most simplest way.

P.S. This is an awesome community where i took most of my programming lessons. Thanks in advance.

Update: thanks a lot guys. Found a solution finally using xml parsing with etree. In my view,

 {{for i in tree: }}
    {{=TAG    [i.tag]    (i.text)}}
    {{pass }}

Guess what? Works amazing!

Upvotes: 1

Views: 1690

Answers (1)

Anthony
Anthony

Reputation: 25536

If you just want to insert some HTML into a page without it being escaped, you can use the XML() helper:

{{=XML(your_html)}}

If you want to include the contents of a file, you can do:

{{include 'path/to/file'}}

Note, the path is relative to the application's /views folder, so if it is outside of that folder, you can start the path with ../.

Upvotes: 3

Related Questions