python - How to include a dynamic page contents into a template? -


I have to include dynamic page content in my template, say I have a left panel that is visible through a view Dynamically retrieves the data Now, I have to add this left panel to all my pages, but I do not want to copy the code for all the pages.

Thanks in advance.

What you are trying to achieve is directly supported in all template languages ​​that I know . I strongly recommend using Python for many good options:

  • < / Li>

If you are using For example (the default template language in web application framework) looks like something you want to do:

  & lt; Html xmlns = "http://www.w3.org/ 1999/XHtml" xmlns: py = "http://genshi.edgewall.org/" xmlns: xi = "http://www.w3.org/2001 / XInclude "P: strip =" "& gt; & Lt; Xi: include href = "header.html" /> & Lt; Xi: include href = "sidebar.html" /> & Lt; Xi: include href = "footer.html" /> & Lt ;! - Your remaining page goes here - & gt; & Lt; Html & gt;  

header.html , sidebar.html and footer.html should be defined only once Can be reused and used in any other page.


Comments