remove switch test for null/undefined and replace it with a tagged template literal
Yamboy1 opened this issue · comments
Yamboy1 commented
instead of checking for null/undefined with a switch statement like we are now:
switch(v[1]) {
case undefined:
case null:
return `<${tagname}>${c[1]}</${tagname}>`;
break;
default:
return `<${tagname} ${v[1]}>${c[1]}</${tagname}>`;
break;
}
we can replace it with a tagged template literal, which will convert any undefineds or nulls into empty strings. It would then be just a single line:
return stripEmpty`<${tagname} ${v[1]}>${c[1]}</${tagname}>`;
Note: I have already made this function/tag, and I know that it works
Yamboy1 commented
more information on tagged templates: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_templates
Yamboy1 commented
Im almost finished inplementing this 😃
Noah Trupin commented
Thank you.