Common Template Engine Release | Build >>  English | 中文
Downloads Changes Log Forums About Us
Documents
Overview
Template Reference
Expression Reference
Syntax Coat Reference
Config Guide
Expansion Guide
API Guide
FAQ
Versus Other Engine
Integration
MVC Integration
JSP Integration
Cache Integration
Logger Integration
Data Format
Javax Script Integration
Mail Sender Integration
Dependency Library
Tools
Debug Window
Viewer
Template Generator
Template Converter
Editor PlugIn
Code Case
Development
Architecture Specification
Develop Criterion
Project Planning
Requirement
Resources
Downloads
License
Changes Log
UML
Java Doc
Coverage Report
Community
Developer Team
Forums
Wiki
Mail List
Bugs List
Report Bugs Here !

 
Template Generator

1. Define TemplateTask
<taskdef name="commontemplate" classname="org.commontemplate.tools.ant.TemplateTask" classpath="commontemplate.jar"/>

2. Call TemplateTask
<target name="generate">
    <commontemplate destdir="${bin}" configfile="${config}">
        <fileset dir="${src}">
            <include name="**/*.java.ctl" />
        </fileset>
    </commontemplate>
</target>

3. TemplateTask Properties
Property Name Type Description Required
foreachname File 迭代变量名称, 可在其它属性或子标签中通过${foreachname}进行引用 Optional
foreachlist File 迭代数据列表,数据项以逗号分隔. Optional
basedir File 相对路径基目录, 其它属性或子标签配置的相对路径都基于目录 Optional
configfile File commontemplate.properties配置文件, 默认采用标准配置 Optional, Alternative to "configclass" property
configclass String org.commontemplate.config.Configuration实现类类名 Optional, Alternative to "configfile" property
classpath String configfile中配置的类以及configclass所在路径 Optional, Alternative to "classpathref" property
classpathref Path configfile中配置的类以及configclass所在路径引用,
对应标签:<path id="XXX">的ID值.
Optional, Alternative to "classpath" property
dir File 模板所在目录, 等同于子标签<fileset dir="XXX"> Required, Alternative to "fileset" sub task
includes String 逗号分隔的包含文件名(或通配符表达式),
等同于子标签<fileset includes="XXX">
或者<fileset><include name="XXX"></fileset>
Optional
excludes String 逗号分隔的排除文件名(或通配符表达式),
等同于子标签<fileset excludes="XXX">
或者<fileset><exclude name="XXX"></fileset>
Optional
defaultexcludes Boolean 是否排除Ant默认排除的文件, 如.svn等,
等同于子标签<fileset defaultexcludes="XXX">
Optional, Default true
inputencoding String 读取模板的输入编码 Optional
data String 直接数据 Optional, Alternative to "datafile" property
datafile File 数据文件 Optional, Alternative to "data" property
datatype String 数据类型, 如:xml, json, properties, yaml等 Optional
dataencoding String 读取数据文件的输入编码 Optional
destdir File 生成结果目标目录 Required
destfileprefix String 目标文件名称前缀(将添加在文件名的前面) Optional
destfilesuffix String 目标文件名称后缀(将添加在文件名后面,扩展名前面) Optional
deleteextension String 多重扩展名删除, 可用逗号隔开多个扩展名, 如: Dao.java.ctl Optional, Default ".ctl"
outputencoding String 生成结果的输出编码 Optional
 

Copyright © 2007 - 2009 CommonTemplate Developer Team