Here's the design I've come up with. If you have any thoughts or
suggestions, please speak up! Once the conversation has settled down
for a few days, I'll take some time to implement this.
craig
--cut here--
For a section named SEC, a sub-section named SEC-separator has a
special meaning. Every time we expand SEC, except for the last time,
we also expand SEC-separator exaclty once. Here's an example:
Here are the meeting attendees:
{{#SEC}}
{{NAME}}
{{#SEC-separator}}, {{/SEC-separator}}
{{/SEC}}
.
Here's something more crazy: a convoluted date specifier.
{{#DATE}}{{DATE_COMPONENT}}{{#DATE_separator}}{{SEP}}{{/DATE_separator}}{{/DATE}}
You'd set up a template dictionary to repeat DATE three times, with
DATE_COMPONENT set to the month, day, and year (or day, month, and
year :-) ), and SEP set to "/" or "-" or what-have-you.
Each time DATE_separator emits, it uses the dictionary in place at
that time (so, in the second example, you could modify SEP each time
through). If you decide to add dictionaries for SEC-separator
explicitly, they'll be expanded *in adddition* to the all-but-last
expansion that the template code will do. I can't imagine someone
doing this for any reason other than an Obfuscated Ctemplate contest.
One reason I wanted SEP-separator instead of SEP_separator (the
proposal is for SEP-separator right? The date example should be fixed
:) is that the k.._... variable cannot be generated for C++.
--
Thanks,
Jim
http://phython.blogspot.com
Right, the DATE example had a typo and said DATE_separator instead of
DATE-separator, which is the new proposed syntax. Here's the
corrected proposal:
{{#DATE}}{{DATE_COMPONENT}}{{#DATE-separator}}{{SEP}}{{/DATE-separator}}{{/DATE}}
craig
I've been playing around with the new syntax, and I have to admit it
just doesn't look right to me. I'm going back to the original idea of
DATE_separator (rather than DATE-separator) as the name. If that
turns out to not be a favorite of folks, we can switch back to the
hyphen.
craig