Closed mjvankampen closed 6 years ago
Thank you for reporting your issue. I will test and try to fix it later today.
I've fixed it and uploaded new version of the extension to Visual Studio Marketplace. The problem was caused by the way custom variables constructor javascript file is loaded. Extension uses 'node require' to load it. It loads file only once, so exports cannot contain calculated values as they would be assigned when we run template engine for the first time. New version of the extension expects 'createVariables(variables)' function to be exported from your javascript instead of list of variables. It should look like this example:
module.exports={
createVariables: function(variables) {
variables.capsafeitemname = variables.safeitemname.toUpperCase();
}
};
I don't want to break any existing functionality, so If createVariables function is not exported from the js file, it will work as before expecting list of variables instead of a single function.
Works like a charm for me! Thank for your awesome and quick response. Now I can generate proper header guards in Cpp!
I am trying to capatalize safeitemname, but it does not seem to update. So the first file created is ok, every one after that has the same capsafeitemname. I'm not sure if this is due to my not existant JS skills or that the customvars is only run once. Iwould say it is run every time by projectItemTemplateManager.js
I use the following in customVars.js
variables = global.vzfiletemplates.variables;
capsafeitemname = variables.safeitemname; capsafeitemname = capsafeitemname.toUpperCase();
module.exports={ capsafeitemname:
${capsafeitemname}
};