Thymeleaf Interactive Tutorial

Exercise 17: comments

This exercise features the different types of comments you can use inside a Thymeleaf template. See the relevant sections on comments of the What's New article.

  1. You'll see four sections marked with the literals [1], [2], [3] and [4].
  2. HTML comment: we want text [1] to be an HTML comment. This comment will be shown in both source and generated code.
  3. Thymeleaf comment: we want text [2] to be a parser-level comment. This comment will be shown in source code but not in generated HTML.
  4. Generated-only content: we want section [3] to be shown when the template is executed but not when it is opened statically.
  5. Prototype-only content: we want section [4] to be shown when the template is opened statically but not when it is executed.
  6. You can check the proposed solution by pressing the Show solution button () above the code editor.

Welcome to the Thymeleaf Interactive Tutorial. Thymeleaf version used in this tutorial is 2.1.5.RELEASE.

This interactive tutorial has been created by the Thymeleaf Team using The Thymeleaf Template Engine and other great open source tools like:

The tutorial is gracefully hosted at the Heroku Cloud Platform

Icons used in this app, except Thymeleaf logo, are created by Mark James

You can get the source code of this tutorial at GitHub.

You can find much more documentation on Thymeleaf at the Thymeleaf website.

For any questions or help, you can use the user forum.

Source code

Static view

Generated source

Dynamic view