2
0
Fork 0
tcrud/lib/plugin/auto/tentity/auto-tentity-tcode.js

25 lines
636 B
JavaScript
Raw Permalink Normal View History

2017-06-10 14:53:29 +00:00
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);
};
};
})();