Issue 58 in json-template: Add a LISP-style "let" statement

6 views
Skip to first unread message

json-t...@googlecode.com

unread,
Nov 5, 2010, 2:10:03 AM11/5/10
to json-t...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 58 by elijahr: Add a LISP-style "let" statement
http://code.google.com/p/json-template/issues/detail?id=58

Sometimes it would be nice to have an explicit way of assigning the value
of one name to another so that, in situations where there is a name
collision, the template writer could be specific about choosing which name
they wanted rather than not have access to names higher up in the scope
chain. A good example of such a collision is detailed in issue #52 with
the name "url".

I think a "let" statement, such as LISP's, would work well here.

For example, here's the template and expansion dictionary from issue #52
and the documentation, with a "let" statement added.

{.section songs}
<h2>Songs in '{playlist-name}'</h2>
{.let playlist-url url}
<table width="100%">
{.repeated section @}
<tr>
<td><a href="{url-base|htmltag}{url|htmltag}">Play</a>
<td><i>{title}</i></td>
<td>{artist}</td>
<td><a href="{url-base|htmltag}{playlist-url|htmltag}">Link to
playlist</a>
</tr>
{.end}
</table>
{.end}
{.or}
<p><em>(No page content matches)</em></p>
{.end}

... combined with a data dictionary ...

{
"url": "happy!",
"url-base": "http://example.com/music/",
"playlist-name": "Epic Playlist",
"songs": [
{
"artist": "Grayceon",
"title": "Sounds Like Thunder"
},
{
"url": "2.mp3",
"artist": "Thou",
"title": "Their Hooves Carve Craters in the Earth"
}
]
}

Perhaps it is not the best example to illustrate the usefulness of this
language addition, but hopefully it is clear that it does solve an actual
problem.


Reply all
Reply to author
Forward
0 new messages