freemarker自定义标签(一)

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>


原文地址:https://www.cnblogs.com/hzcya1995/p/13315045.html