keet
Version:
Minimalist view layer for the web
28 lines (21 loc) • 1.01 kB
Markdown
---
id: ternary
title: Ternary State
sidebar_label: Ternary State
---
## Handling Boolean State
Often times with Javascript we use boolean as variables, but usually when parsing the result to DOM we want it in a different form. In this case we use ternary operator as our state expression i.e ```{{<state>?<truthy>:<falsy>}}```.
```js
import Keet from 'keet'
class App extends Keet {
el = 'app'
status = false
render(){
return 'Hello {{status?World:Keet}}'
}
}
const app = new App()
```
## Codepen Sample
<p data-height="265" data-theme-id="dark" data-slug-hash="eLGqPP" data-default-tab="js,result" data-user="syarul" data-pen-title="Keetjs - Ternary State" class="codepen">See the Pen <a href="https://codepen.io/syarul/pen/eLGqPP/">Keetjs - Ternary State</a> by Shahrul Nizam b. Selamat (<a href="https://codepen.io/syarul"></a>) on <a href="https://codepen.io">CodePen</a>.</p>
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>