mediawiki-extensions-Visual.../modules/parser/ext.core.BehaviorSwitchHandler.js
Gabriel Wicke 9f753d8009 Source-based round-tripping for behavior switches
Change-Id: I46d12d338314a8dbfdc9a8448a74680e67c3a720
2012-06-28 18:20:13 +02:00

30 lines
660 B
JavaScript

/**
*/
function BehaviorSwitchHandler( manager, isInclude ) {
this.manager = manager;
this.manager.addTransform( this.onBehaviorSwitch.bind( this ), this.rank, 'tag', 'behavior-switch' );
}
BehaviorSwitchHandler.prototype.rank = 2.14;
BehaviorSwitchHandler.prototype.onBehaviorSwitch = function ( token, manager, cb ) {
var env = this.manager.env,
magic_word = token.attribs[0].v;
env.setVariable(magic_word, true);
return { tokens:
[
new SelfclosingTagTk( 'meta',
[ new KV( 'data-gen', 'both' ) ],
token.dataAttribs )
]
};
};
if (typeof module == "object") {
module.exports.BehaviorSwitchHandler = BehaviorSwitchHandler;
}