<div rt-scope="[1,2,3] as z" rt-repeat="item in z">
<div>{item}</div>
</div>
produces
Uncaught ReferenceError: z is not defined
The problem seems to be rt-scope and rt-repeat attributes appearing on the same tag.
Anyway by looking at the source code, this seems something that has been worked on and that presumably worked in the past:
// Order matters. We need to add the item and itemIndex to context.boundParams before
// the rt-scope directive is processed, lest they are not passed to the child scopes
and also:
// Order matters here. Each rt-repeat iteration wraps over the rt-scope, so
// the scope variables are evaluated in context of the current iteration.
As a fix to this problem, I propose to change the way injected functions are generated. Instead of having them all at the top level, we can nest functions the same way they appear in the template, thus making scope/naming automatic.
Example of how would be rendered the template shown above:
var templateRT = function () {
function scope1() {
function repeat2(item, itemIndex) {
return React.createElement('div', {}, React.createElement('div', {}, item));
}
var z = [1, 2, 3];
return _.map(z, repeat2.bind(this));
}
return scope1.apply(this);
};
The following template
produces
The problem seems to be
rt-scope
andrt-repeat
attributes appearing on the same tag.Anyway by looking at the source code, this seems something that has been worked on and that presumably worked in the past:
and also:
As a fix to this problem, I propose to change the way injected functions are generated. Instead of having them all at the top level, we can nest functions the same way they appear in the template, thus making scope/naming automatic.
Example of how would be rendered the template shown above:
This change would be beneficial also for #156