Chapter 3

Designing Templates

IN THIS CHAPTER

Bullet Using elements

Bullet Commenting your template

Bullet Rendering conditionally

Bullet Looping

Bullet Using text expressions

Bullet Inserting into slots

“Language exerts hidden power, like the moon on the tides.”

—RITA MAE BROWN

At first glance, Svelte template code is just HTML. When you investigate it further, however, Svelte provides a wealth of additional features and functions you can use. In this chapter, you'll learn the syntax and commands that help to create dynamic user interfaces in Svelte.

Elements Are the Building Blocks

As in React and Vue, Svelte templates are made up of built-in and custom elements that create instances of components.

Using the built-in elements

The built-in components match all of HTML's elements, and the attributes that are available for built-in components also match HTML's. If you know how to write valid HTML5 code, you can write a ...

Get JavaScript All-in-One For Dummies 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.