【问题标题】:Thymeleaf - Parsing external CSS file? Expressions, variables etcThymeleaf - 解析外部 CSS 文件?表达式、变量等
【发布时间】:2017-03-29 00:17:34
【问题描述】:

我似乎找不到任何具体的答案,尽管我更倾向于说这是不可能的。

但是,是否可以在外部 CSS 文件中使用 Thmymeleaf 表达式?例如,如果我有 ma​​in.css 并且它包含:

body {
    font-size: [[${fooBean.isLarge ? '22px;' : '16px;' }]];
}

.header {
    margin-top:
    background: url{[[${fooBean.isMain ? '/img/blue.jpg' : '/img/red.jpg' }]]}
                    no-repeat center center fixed;
}

这完全可以使用 Thymeleaf 吗?

【问题讨论】:

    标签: css spring thymeleaf


    【解决方案1】:

    Thymeleaf 3 introduced new template modes。其中之一是 CSS,you can see an example of one here。您必须设置所有的弹簧材料/控制器,但您应该能够像平常一样使用它们(将您的 fooBean 添加到模型中)。

    【讨论】:

    • 谢谢!这正是我想要的。
    猜你喜欢
    • 2019-01-04
    • 1970-01-01
    • 2017-02-27
    • 2016-01-21
    • 2017-03-28
    • 1970-01-01
    • 1970-01-01
    • 2018-09-29
    • 2013-04-13
    相关资源
    最近更新 更多