Writing templates

We need to use template language to write component templates. Template language is composed of HTML along with the {}, [], (), [()], *, |, and # tokens. Let's see what each of these is used for and how to use them.

Rendering a value

To simply render a property of the this keyword, we need to use the {{}} token. Inside these braces, we can simply place the property name.

We can only place expressions inside braces. The expressions we place inside them look like JavaScript. But there are a few JavaScript expressions that we are not allowed to use inside these braces. Here they are:

  • Assignments (=, +=, -=)
  • The new operator
  • Chaining expressions with ; or ,
  • Increment and decrement operators (++ and --)
  • The bitwise operators | and &

Pipes ...

Get JavaScript: Moving to ES2015 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.