How to Insert parametrized fragment into meta tag of the template

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to Insert parametrized fragment into meta tag of the template

RollerBlade
I use Thymeleaf 3.0.3 with spring boot 1.5.1. I managed to use parametrized fragment that was defined like this:
<head data-th-fragment="head-section(title,description)">

<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
    rel="stylesheet" />

<link type="text/css" rel="stylesheet"
    href="../../static/css/materialize.css"
    data-th-href="@{css/materialize.css}" media="screen,projection" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="[(${description})]" />
<title data-th-text="${title}">components</title>
</head>

In case of title the expression is evaluated good but in terms of <meta name="description" content="[(${description})]" /> is not correct. What should be used here?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to Insert parametrized fragment into meta tag of the template

Metroids
<meta name="description" data-th-attr="content=${description}" />
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to Insert parametrized fragment into meta tag of the template

RollerBlade
Thanks Metroids,
It is working. I completely forgot the th-data-attr althgough it is n the documentation.

Roland
Loading...