`

freemarker fmpp的使用

阅读更多
1.下载fmpp http://fmpp.sourceforge.net/

2.解压缩在如F:\work下
 

3.环境变量path中设置F:\work\fmpp\bin


4.在F:\work下建立如下的文件夹和配置文件
 
  文件夹src下存放ftl模板文件,data下存放数据模型,out下运行fmpp后生成的输入html文件,config.fmpp是fmpp的配置文件。

5.src下建立product.ftl文件
<html>
<head>
  <title>Welcome!</title>
</head>
<body>
  <h1>Welcome ${user}!</h1>
  <p>Our latest product:
  <a href="${latestProduct.url}">${latestProduct.name}</a>!
  
  <#if 1==1>
  <h1>if语句</h1>
  </#if>
</body>
</html>


6.data下建立product.tdd文件
{
	user: "Big Joe"
	latestProduct: {url: "products/greenmouse.html", name: "Green Mouse"}
}


7.config.fmpp文件内容
sourceRoot: src
outputRoot: out
logFile: log.fmpp
modes: [
 copy(common/**/*.*, resource/*.*)
 execute(*.ftl)
 ignore(templates/*.*, .project, **/*.xml, xml/*.*, *.js)
]
replaceExtensions: [ftl, html]
sourceEncoding: gb2312
data: tdd(../data/product.tdd)

 
8.cmd进入F:\work下,输入fmpp,则out文件夹下产生product.html文件
<html>
<head>
  <title>Welcome!</title>
</head>
<body>
  <h1>Welcome Big Joe!</h1>
  <p>Our latest product:
  <a href="products/greenmouse.html">Green Mouse</a>!
  
  <h1>if语句</h1>
</body>

</html>



  • 大小: 12.8 KB
  • 大小: 6.9 KB
  • 大小: 17.9 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics