freemarker自定义标签(一)

时间:2021-12-04 07:02:56

freemarker自定义标签

1、自定义标签说明

宏变量存储模板片段可以被用作自定义指令macro

2、示例说明

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>freemarker自定义标签</title>

  </head>

  <body>
     <#--freemarker自定义标签-->
	 <#macro write>
	     repeat("张三丰",3)
	 </#macro>

	 <@write/>
  </body>
</html>

3、示例结果

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>freemarker自定义标签</title>

  </head>

  <body>

	     repeat("张三丰",3)
  </body>
</html>