There is a function preprocess() in the fileheader library that will filter out any user-configurable setting options, such as turning off the description or email tag. When these are turned off in the settings, they will be removed from the template by preprocess() function so that they will not be rendered. This means that they can still be present in the template, but the template renderer will not display if the user turns them off.
Currently, there is an if() block that manually removes each option if it is turned off. This uses a string.split.filter and if it reads, for example, @description, it simply says
return line.indexOf(@Description) == -1 || option.description &&
line.indexOf(@AnotherField) == -1 || option.anotherField &&
// and so on for all the fields we need
This one return line will grow whenever we add a new option. The logic is correct, its just that it needs manually updating. There is even a TODO in the code that says this.
This could be made automatic, so that instead of an if...if...if... block that needs manually updating when a new option is added, we can just change this line so that it has a for loop, with the return being changed to
include = true;
for(i = 0; i < option.length; i++) {
include = include && line.indexOf('@' + option[i].name) || option[i])
}
return include
For the two extra lines of code we get an auto-updating options preprocessor!
There is a function preprocess() in the fileheader library that will filter out any user-configurable setting options, such as turning off the description or email tag. When these are turned off in the settings, they will be removed from the template by preprocess() function so that they will not be rendered. This means that they can still be present in the template, but the template renderer will not display if the user turns them off.
Currently, there is an if() block that manually removes each option if it is turned off. This uses a
string.split.filterand if it reads, for example, @description, it simply saysThis one return line will grow whenever we add a new option. The logic is correct, its just that it needs manually updating. There is even a TODO in the code that says this.
This could be made automatic, so that instead of an if...if...if... block that needs manually updating when a new option is added, we can just change this line so that it has a for loop, with the return being changed to
For the two extra lines of code we get an auto-updating options preprocessor!