UNPKG

conditional-tag

Version:

Clean, easily readable conditional statements in template literals/strings for Node.js and browsers. Provides `if` / `elseif` / `else` and `switch` / `case` / `default` syntax options.

30 lines (24 loc) 416 B
const condTrue = Symbol('condTrue'); const condFalse = Symbol('condFalse'); function _if(condition) { return { func: 'if', cond: (condition) ? condTrue : condFalse }; } function _elseif(condition) { return { func: 'elseif', cond: (condition) ? condTrue : condFalse }; } const _else = Symbol('else'); const _endif = Symbol('endif'); export { _if, _elseif, _else, _endif, condTrue, condFalse };