Danny Navarro's Blog

Stochastic Trains of Thought

Commenting Out in Chamaleon Templates

If you want to prevent Chameleon from rendering some portions of an HTML template you might be tempted to do something like this:


<!-- <div>${context.name}</div> -->

However Chameleon will still evaluate what’s inside the ${…} block even if it’s within an HTML comment. Chameleon must do this because you might want to insert conditional comments.

This dummy tal:condition block will do the job:


<span tal:condition="None"> <div>${context.name}</div> </span>

Chameleon ignore anything inside the condition block.