gsf/whiskers.js — pull request #10 by mobilana (2012-02-10 10:04:11+00:00)
Title: Current context identity via 'self' attribute

Objectives: improve reusability of partials

Problem statement: the loop defines a named context that is referenced-by-name from nested objects, e.g. {for e in entry}{e.title}{/for}. If the loop includes partials then named context is propagated to partials as well.
If follows that context name must be aligned across template and partials. As an example

template = '{for e in entry}{>common}{>other}{/for}'
partials: {
other: '{for i in item}{>common}{e.owner}{/for}'
common: '{e.title}'
}
This scenario would not work, partial common is not reusable and you cannot use same context name whithin both loops (the previous context is used in inner loop)

Solution: along with a named-context use a common name (e.g. self) that always reflect the current context so that partial becomes common:'{self.title}' and it is re-usable.

See test-partials.js for example