Skip to content. | Skip to navigation

Personal tools

Navigation

You are here: Home / Members / jhb / checked and selected in chameleon templates

checked and selected in chameleon templates

by Jörg Baach last modified Apr 06, 2022 06:35 AM
How to activate boolean attributes

When using chamelon templates using selected or checked as attributes in tal:attributes seems to fail, as the tag is rendered with something like selected=False.

The solution is somewhat hidden in the documentation. The solution is to activate boolean_attributes on the template:

template = PageTemplate("<input type="checkbox" tal:attributes="checked True" />",
boolean_attributes={"selected", "checked"})
// or

templates = PageTemplateLoader(path, boolean_attributes={"selected", "checked"})

I've created a pull request.

Update: pull request got accepted, yeah \o/

Add comment

You can add a comment by filling out the form below. Plain text formatting.

Question: What is 42 minus 19?
Your answer: