Lucio
2010-02-25 21:47:57 UTC
Hi all,
I couldn't find any relevant threads about my question. Feel free to
redirect me if I missed something obvious.
Asking by example may be simpler. Say I have the following script:
#! /usr/bin/env python
import jsontemplate
tmpl = """
{.repeated section a}
{@}
{.end}
"""
result = jsontemplate.expand(tmpl, dict(
a = [1, 2, 3, 4],
b = list("abcd"),
))
print result
It produces this output:
1
2
3
4
Now I'd like to output the elements of 'a' and 'b' side by side, in
parallel, to produce something like:
1 a
2 b
3 b
4 d
Is there any way to achieve this at the template level (i.e., without
transforming my dict)?
I am looking for something in the lines of this hypothetical syntax:
{.repeated section a}
{@} {***@index}
{.end}
or:
{.repeated section a b}
{@.a} {@.b}
{.end}
Thanks!
--lucio
I couldn't find any relevant threads about my question. Feel free to
redirect me if I missed something obvious.
Asking by example may be simpler. Say I have the following script:
#! /usr/bin/env python
import jsontemplate
tmpl = """
{.repeated section a}
{@}
{.end}
"""
result = jsontemplate.expand(tmpl, dict(
a = [1, 2, 3, 4],
b = list("abcd"),
))
print result
It produces this output:
1
2
3
4
Now I'd like to output the elements of 'a' and 'b' side by side, in
parallel, to produce something like:
1 a
2 b
3 b
4 d
Is there any way to achieve this at the template level (i.e., without
transforming my dict)?
I am looking for something in the lines of this hypothetical syntax:
{.repeated section a}
{@} {***@index}
{.end}
or:
{.repeated section a b}
{@.a} {@.b}
{.end}
Thanks!
--lucio
--
You received this message because you are subscribed to the Google Groups "JSON Template" group.
To post to this group, send email to json-template-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to json-template+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/json-template?hl=en.
You received this message because you are subscribed to the Google Groups "JSON Template" group.
To post to this group, send email to json-template-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to json-template+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/json-template?hl=en.