A directive that, given a condition, chooses between two inputs: ifTrue and ifFalse. If ifFalse is omitted (which is allowed), the false case defaults to undefined, which won't get rendered at all inside of an HTML template.
ifTrue
ifFalse
undefined
Optional
import {html, defineElement, renderIf} from 'element-vir';const MyElement = defineElement()({ tagName: 'my-element', render() { return html` <div> ${renderIf( Math.random() > 0.5, html` True! `, html` False! `, )} </div> `; },}); Copy
import {html, defineElement, renderIf} from 'element-vir';const MyElement = defineElement()({ tagName: 'my-element', render() { return html` <div> ${renderIf( Math.random() > 0.5, html` True! `, html` False! `, )} </div> `; },});
A directive that, given a condition, chooses between two inputs:
ifTrueandifFalse. IfifFalseis omitted (which is allowed), the false case defaults toundefined, which won't get rendered at all inside of an HTML template.