Skip to content

JavaScript expressions ​

While JavaScript is very similar to Python, they are still different. This page aims to provide some usage examples of what you could be using in your trame/vue template.

String templating ​

html
<b>static {{ dynamic }}</b>

<b>
  static 
  {{ message.split(' ').reverse().join(' ') }}
</b>
html
<widget  :label="`static ${dynamic}`" />

Ternary evaluation ​

html
<b>static {{ ok ? 'yes' : 'no' }}</b>
html
<widget  :label="`static ${ok ? 'yes' : 'no'}`" />

Conditions ​

js
a && b || c
js
// a=2, b='2' => true
a == b

// a=2, b='2' => false
a === b

// c='4' => true
c > 3
js
// obj={a:{b:[1,2,3]}}
obj?.a?.b?.[6]
js
['a', 'b'].includes(search)