Skip to content

Commit

Permalink
Evaluate template arguments in caller's NLS context
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxMotovilov committed Nov 8, 2014
1 parent 9ea6ab8 commit eddf691
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
30 changes: 13 additions & 17 deletions libs/dojox/jtlc/CHT.js
Expand Up @@ -228,19 +228,6 @@ dojo.declare( 'dojox.jtlc.CHT', dj._qplusL, {
var stack = [],
lit_seq_start = -1;

function wrapInContext( at ) {
if( refs[tag].context ) {
body.splice( at, 1,
_this._contextSwitch( refs[tag].context, 'enter' ),
body[at],
_this._contextSwitch( refs[tag].context, 'exit' )
);
i += 2;
return true;
}
return false;
}

function unwrapFromContext( body ) {
body.unshift( _this._contextSwitch( refs[tag].context, 'exit' ) );
body.push( _this._contextSwitch( refs[tag].context, 'enter' ) );
Expand Down Expand Up @@ -313,8 +300,7 @@ dojo.declare( 'dojox.jtlc.CHT', dj._qplusL, {
body[i].def_sections = def_sections;
body[i].sections = [];
} else { // non-sectioned element (widget)
body[i] = refs[tag].tag( _this, body[i] );
wrapInContext( i );
body[i] = refs[tag].tag( _this, body[i], null, refs[tag].context );
}
}
} else { // body[i].closeTag
Expand Down Expand Up @@ -342,10 +328,10 @@ dojo.declare( 'dojox.jtlc.CHT', dj._qplusL, {

if( !parent.body.length ) delete parent.body;

body[stack[0]] = refs[tag].tag( _this, parent, ns[elt_name] );
body[stack.shift()] = refs[tag].tag( _this, parent, ns[elt_name], refs[tag].context );
body.splice( i--, 1 );

if( wrapInContext( stack.shift() ) ) {
if( refs[tag].context ) {
dojo.forEach( parent.sections, function(s){ unwrapFromContext( s.body ); } );
if( parent.body && parent.body.length ) unwrapFromContext( parent.body );
}
Expand Down Expand Up @@ -493,6 +479,16 @@ dojo.declare( 'dojox.jtlc.CHT', dj._qplusL, {
}
},

_inContext: function( ctx, what ) {
return {
compile: function() {
ctx.enter( this );
this.compile( what );
ctx.exit( this );
}
}
},

_userDefinedElement: dj.CHT.userDefinedElement,

_attributeSlots: function( elt ) {
Expand Down
4 changes: 3 additions & 1 deletion libs/dojox/jtlc/CHT/userDefinedElement.js
Expand Up @@ -173,13 +173,15 @@ dojo.declare( 'dojox.jtlc.CHT.userDefinedElement', null, {
}
),

tag: function( cht, elt ) {
tag: function( cht, elt, _, ctx ) {

var t = this.kwarg.compiled && elt.openTag
? new cht._appendToOutput( [ new this._compiledTag( cht, elt, new this._tag( cht, {}, this ) ) ] )
: new this._tag( cht, elt, this ),
slots = cht._attributeSlots( elt );

if( ctx ) t = cht._inContext( ctx, t );

if( slots ) return dojox.jtlc.tags.scope( t, slots );
else return t;
},
Expand Down

0 comments on commit eddf691

Please sign in to comment.