2
0
Fork 0
tcrud/lib/plugin/auto/tentity/auto-tentity-tcode.js
2017-06-10 16:53:29 +02:00

25 lines
636 B
JavaScript

module.exports = (function () {
var filterCode = function(ctx,value) {
return ctx.filterValue(value,[' ','_','-','.',','],'',function (part) {
return part.toLowerCase();
});
}
return function AutoTEntityTCodePlugin() {
this.configPlugin = function (ctx) {
ctx.key='autoTEntityTCode';
ctx.description='Fills and filters tcode to be code-safe for generating variables/functions.';
};
this.fillTEntity = function(ctx) {
if (ctx.tentity.tcode === null || ctx.tentity.tcode === null) {
ctx.tentity.tcode = ctx.tentity.tid;
}
ctx.tentity.tcode = filterCode(ctx,ctx.tentity.tcode);
};
};
})();