Say I had a chameleon template file for a user object with something like this:
<h2><tal:content="user.name"></h2>
<h4><tal:content="user.occupation"></h4>
<p><tal:content="user.bio"></p>
Can I loop over a list of users in another template file to fill multiple content slots like below?
<tal:block repeat="user users">
<div metal:define-slot='user'></div> <!-- ??? -->
</tal:block>
I imagine this may be useful if a page has a list of complicated objects with a lot of data to display, but I can't find anything about it and I don't know what search terms to give google.
Right now I just have something like this:
<tal:block repeat="user users">
<h2><tal:content="user.name"</h2>
<h4><tal:content="user.occupation"></h4>
<p><tal:content="user.bio"></p>
</tal:block>
which is good enough for me, but I was just wondering if what I am asking is possible.
What you're looking for are metal macros. They are confusing at first, but super powerful once you get your head around them.
https://chameleon.readthedocs.org/en/latest/reference.html?highlight=metal#metal
HTH