Links

HTML Template Directives - Salesforce Lightning Component Library

Render DOM Elements Conditionally - Salesforce Lightning Component Library

Render Lists - Salesforce Lightning Component Library

Introduction

The template is created using HTML. Not all elements that you code in the HTML appear to the end user, as you can use conditional rendering.

The following is an example of the translation that LWC provides:

<template>
	<div class="slds-var-m-around_medium">
		My First LWC!!
	</div>
</template>

Is translated to:

<c-my-first-lwc>
	<div class="slds-var-m-around_medium">
		My First LWC!!
	</div>
</c-my-first-lwc>

Bind a variable to a Javascript Property

Look at the following example for a template and a Javascript files, where the template uses a property:

<template>
	<p>Hello, {greeting}!</p>
		<lightning-input label="Name" value={greeting} onchange={handleChange}>
		</lightning-input>
</template>
import { LightningElement } from ‘lwc’; 
export default class HelloBinding extends LightningElement { 

	greeting = 'World';
	handleChange(event) {
	    this.greeting = 'touché' ; //<-- The value in the event
	}
}