mania
mania

Reputation: 1

How can I extend my template with thymeleaf?

I'd like to get a view that displays these two files in one page. I've followed syntax but yet I'm unabled to get a proper view.

Layout page:

<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">

    <body>
        <div layout:fragment="content">
            <p>Changing contents</p>
        </div>
    </body>
</html>

Content page:

<!DOCTYPE html>
<html lang="en"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorate="skeleton.html"
      xmlns:th="http://www.thymeleaf.org">

  <body>
    <div layout:fragment="content">

      <!--Content of the page-->
      <h3>page injected in another page</h3>

    </div>
  </body>
</html>

The result is just the content of the content page with this text: page injected in another page

Could anyone say me what's wrong with my code please?

Upvotes: 0

Views: 1231

Answers (1)

Slava Ivanov
Slava Ivanov

Reputation: 6912

For layout:decorate you need to use Standard Expression Syntax, something like ... layout:decorate="~{skeleton}" will work, depend on the location of your skeleton.html file.

Upvotes: 1

Related Questions