ntrupin / abstractml

An HTML abstraction focused on simplicity, with support for JavaScript and CSS. Perfect for experts and beginners!

Home Page:https://ntrupin.github.io/abstractml/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

remove switch test for null/undefined and replace it with a tagged template literal

Yamboy1 opened this issue · comments

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

Im almost finished inplementing this 😃

Thank you.