如何在生成的 HTML 中未包含的 Thymeleaf 模板中添加源代码注释? [英] How to add source code comments in Thymeleaf templates that don't get included in generated HTML?

查看:30
本文介绍了如何在生成的 HTML 中未包含的 Thymeleaf 模板中添加源代码注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在中型 Web 应用程序中使用全栈 Thymeleaf(spring mvc、安全性、布局方言、webflow).

好的..既然我们在 html 模板中放置了如此多的代码,那么最好包含未包含在生成的 HTML 文件中的源代码注释.

我们如何实现这一目标?

解决方案

2.1 版已发布,现在您可以升级库并在代码中使用注释.在这个版本中,开发者可以使用解析器级别的注释块:

<!--/* 此代码将在 thymeleaf 解析时移除!*/-->

和仅限原型的注释块:

你好!<!--/*/<div th:text="${...}">

/*/--><span>再见!</span>

详细解释可以在这里的官方文档中找到:http://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#comments-and-blocks

I am using full stack Thymeleaf (spring mvc, security, layout dialect, webflow) in a mid-size web application.

Ok..now that we put so much of code in the html templates it would be nice to include source code comments that don't get included in the generated HTML file.

How do we achieve that?

解决方案

Version 2.1 is released so now you can upgrade your libraries and use comments in your code. With this version developers are able to use parser-level comment blocks:

<!--/* This code will be removed at thymeleaf parsing time! */-->

and prototype-only comment blocks:

<span>hello!</span>
<!--/*/
    <div th:text="${...}">

</div>
/*/-->
<span>goodbye!</span>

Detailed explanation can be found in the official documentation here: http://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#comments-and-blocks

这篇关于如何在生成的 HTML 中未包含的 Thymeleaf 模板中添加源代码注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆