Pyramid, chameleon and template rendering.

I started a project with the Python Pyramid web framework using the chameleon template engine.

I am new to these frameworks, but I have to use it for the client.

I follow the steps to install the framework, then I started coding, just for training purposes!

My first application was a stupid, simple CRUD application.

What am I doing:

in my __init__.py I have the following code for each view:

config.add_view ('myenglishdictionary.views.modify', ROUTE_NAME = 'modify_route', renderer = 'Templates / base.pt')

base.pt is the main template with header and footer and div with the following code:

 <div>${body}</div> 

in my view.py file, each view has two lines, such as:

 body = render('templates/list.pt',{'list':list ,'project':'myProject'}, request=request) return {'body':body} 

and in my .pt list there is content that will be embedded in base.pt

Everything seemed to work well. But after updating the libraries, now I do not see the correct template.

Instead of real html code, there are html objects:

  &lt;div class="clear"&gt;&lt;/div&gt; 

so obviously the page looks bad.

Problems seem to arise in the rendering method, as the html base.pt template is displayed correctly.

+4
source share
1 answer

Using the ${} syntax avoids the included text by default (to protect against XSS injection attacks).

Instead, use the structure: prefix to tell the rendering engine not to move away from your text:

 <div>${structure: body}</div> 
+6
source

All Articles