简体   繁体   中英

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.

PS 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!

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 ../ .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM