| Issue 52: | Use @. to stop scope chain lookup | |
| 2 people starred this issue and may be notified of changes. | Back to list |
A template string ...
{# This is a comment and will be removed from the output.}
{.section songs}
<h2>Songs in '{playlist-name}'</h2>
<table width="100%">
{.repeated section @}
<tr>
<td><a href="{url-base|htmltag}{url|htmltag}">Play</a>
<td><i>{title}</i></td>
<td>{artist}</td>
</tr>
{.end}
</table>
{.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"
}
]
}
... gives output:
<h2>Songs in 'Epic Playlist'</h2>
<table width="100%">
<tr>
<td><a href="http://example.com/music/happy!">Play</a>
<td><i>Sounds Like Thunder</i></td>
<td>Grayceon</td>
</tr>
<tr>
<td><a href="http://example.com/music/2.mp3">Play</a>
<td><i>Their Hooves Carve Craters in the Earth</i></td>
<td>Thou</td>
</tr>
</table>
But in the template, if this line:
<td><a href="{url-base|htmltag}{url|htmltag}">Play</a>
were changed to:
<td><a href="{url-base|htmltag}{@.url|htmltag}">Play</a>
It would return:
<td><a href="http://example.com/music/">Play</a>
instead of :
<td><a href="http://example.com/music/happy!">Play</a>
A complete nonsensical example, but illustrates what I mean I hope!
Feb 17, 2010
Project Member
#1
gtempacc...@yahoo.com
Feb 18, 2010
Yes, I do need it to stop some scenarios from occurring. As I have a system for includes, and a system for doing lookups into the parent chains of includes and their scopes, this starts to happen more often. (I do this by a custom formatter and a custom undefined_str function). So, in such a big system, it happens. (There is a corollary: ^.xxx to, say, look up in reverse order from the top, but I think that introduces something far more new in concept and implementation.) |