[stringtemplate-interest] One more glitch: $it$ in templates invoked on multiple lists
Roman Odaisky
roma at qwertty.com
Sun Sep 7 05:44:27 PDT 2008
Given:
template_v.st
...$v.(a)$...$a$...$b$...
template_it.st
...$it.(a)$...$a$...$b$...
This works:
$[list1], [list2]:{a, b | $template_v(v=var, a=a, b=b)$}
This doesn’t:
$[list1], [list2]:{a, b | $var:template_it(a=a, b=b)$}
The second case results in something that resembles a Cartesian product of the
lists.
In my case, var is a django.forms.ModelForm, and I’ve hacked PyST where it
tests for isinstance(o, dict) to look for __getitem__ instead, to support
dict-like objects that are not dict. I wanted to have
$["field1", "field2"], ["Field 1", "Field2"]:{name,title|
$form:label_and_input(name=name, title=title)$}$
which only works if form becomes a named parameter.
StringTemplate 3.1 for Python.
--
WBR
Roman.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2286 bytes
Desc: not available
Url : http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20080907/70daabda/attachment.bin
More information about the stringtemplate-interest
mailing list