百里香叶变成<style></风格> [英] Thymeleaf into <style>< /style>
问题描述
我将 Polymer 与 Thymeleaf 一起使用,并且我想在未压缩时在 paper-scroll-header-panel 元素中设置背景图像.所以,我正在尝试这个:
I'm using Polymer with Thymeleaf and I want to set a background image in paper-scroll-header-panel element when it's uncondensed. So, I'm trying this:
paper-scroll-header-panel{
--paper-scroll-header-panel-full-header: {
background-image: url("+ @{(${session.user.coverImagePath})} + ");
};
}
但是 Thymeleaf 没有呈现这段代码,当我访问这个模板时,我得到了原样的代码.那么,如何使用 Thymeleaf 设置此属性?
But Thymeleaf is not rendering this code, when I access this template I get the code as it is. So, how can I set this property with Thymeleaf?
推荐答案
你必须明确告诉 Thymeleaf 在文本中查找带有 th:inline
属性的表达式,然后用双方块包围表达式括号.
You have to explicitly tell Thymeleaf to look for expressions in text with th:inline
attribute, and than surround the expression with double square brackets.
<style th:inline="text">
paper-scroll-header-panel{
--paper-scroll-header-panel-full-header: {
background-image: url([[@{(${session.user.coverImagePath})}]]);
};
}
</style>
Thymeleaf 的作者出于性能原因选择了这种方案,因为与 JSP 或 Facelets 相比,Thymeleaf 的模板解析和处理非常不同.
The authors of Thymeleaf have chosen this scheme for performance reasons, because the Thymeleaf's template parsing and processing is very different compared to JSP or Facelets.
这篇关于百里香叶变成<style></风格>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!