`
sillycat
  • 浏览: 2551694 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

FMPP Content Generate(1)Installation and Introduction

 
阅读更多
FMPP Content Generate(1)Installation and Introduction

FMPP is using template engine FreeMarker. It can insert data from sources like CSV, XML and JSON into the generated files.

Download the latest Source and Package
> wget https://versaweb.dl.sourceforge.net/project/fmpp/fmpp/0.9.16/fmpp_0.9.16.tar.gz

Or we can get source codes here
https://github.com/freemarker/fmpp
https://github.com/freemarker/fmpp/tree/master/src/docs/examples

> git clone https://github.com/freemarker/fmpp

Follow document try to build that from master
https://github.com/freemarker/fmpp/blob/master/BUILD.txt
> java -version
java version "1.8.0_161"

> ant -version
Apache Ant(TM) version 1.10.3 compiled on March 24 2018

Prepare the build file
> cp build.properties.sample build.properties

It is not that easy to solve the dependency issues.
Unzip the file and put into working directory
> sudo ln -s /Users/hluo/tool/fmpp-0.9.16 /opt/fmpp-0.9.16
> sudo ln -s /opt/fmpp-0.9.16 /opt/fmpp

Add to PATH, check the installation and version
> fmpp --version
FMPP version 0.9.16, build 2018-09-03T21:47:30Z
Currently using FreeMarker version 2.3.28
For the latest version visit: http://fmpp.sourceforge.net/

Create a demo directory named fmppdemo
Create some working directory in that project
fmppdemo/data/hellosillycat.csv
fmppdemo/data/hellosillycat.tdd
fmppdemo/out
fmppdemo/src/hellosillycat.ftl
fmppdemo/config.fmpp

Here is some details for these files
hellosillycat.tdd is the data file, it can be JSON format data
{
    user: "Yiyi Kang"
    work: "Cloudsnap"
}

hellosillycat.csv is the data file as well, it just can be exported from MySQL database
user;work
Yiyi Kang;Lablue
hellosillycat.ftl is the template for our project, it supports free marker
<html>
    <head>
        <title>fmpp generate html</title>
    </head>
    <body>
        <h1>Welcome ${user}</h1>
        <p>Happy workday in ${work}</p>

        <table border=1>
          <tr><#list csv.headers as h><th>${h}</#list>
        <#list csv as row>
          <tr><#list csv.headers as h><td>${(row[h]!"N/A")?string}</#list>
        </#list>
    </body>
</html>

So fmpp will load the data from data directory, following the template in FTL and generate all the html in out directory.
config.fmpp is the configuration for how to generate
sourceRoot: src
outputRoot: out
logFile: log.fmpp
modes: [
    execute(*.ftl)
]
replaceExtensions:[ftl, html]
data: {
    tdd(../data/hellosillycat.tdd)
    csv: csv(../data/hellosillycat.csv)
}

Some other details in Data Loader
http://fmpp.sourceforge.net/dataloader.html#key_csv

Multiple Files
http://fmpp.sourceforge.net/qtour.html#sect4

For CSV, we can load different set of data.
data: {
    tdd(../data/hellosillycat.tdd)
    csv: csv(../data/hellosillycat.csv)
    devices: csv(../data/devices.csv)
}

For template files, we can generate a lot of different files according to the same template from different data records.
<@pp.dropOutputFile />
<#list devices as device>
<@pp.changeOutputFile name=device.deviceName+".html" />
<html>
    <head> 
      <title>${device.deviceName?cap_first}</title>
    </head>
    <body>
        <h1>${device.deviceName?cap_first}</h1>
          <p>${device.ip}</p>
    </body> 
</html>
</#list>

I will create a file in easy/easyfmpp

References:
http://fmpp.sourceforge.net/
http://fmpp.sourceforge.net/qtour.html

http://liuna718-163-com.iteye.com/blog/1596667
http://philipho123.iteye.com/blog/793124



分享到:
评论

相关推荐

    SQL and ADO Code Generator. Generate SQL statement and ADO C

    SQL and ADO Code Generator. Generate SQL statement and ADO Code Connection without the use of an ADO Data Control.

    Verilog中generate用法

    1. **generate语句类型**: - **generate for**:使用`genvar`关键字定义循环变量,类似于C语言中的for循环。例如: ```verilog genvar i; generate for(i = 0; i ; i = i + 1) begin : block_name // 代码块 ...

    Fmpp+Ant生成类文件

    &lt;target name="generate-sources"&gt; &lt;fmpp outDir="src/main/java" srcDir="templates"&gt; &lt;/fmpp&gt; ``` 在这个例子中,`srcDir`指向包含FreeMarker模板的目录,而`outDir`则是生成的Java源代码将被放置的位置。`...

    codegenerate-3.6.1源码

    《codegenerate-3.6.1源码解析与二次开发指南》 在IT行业中,源码分析和二次开发是提升软件功能、优化性能的重要手段。本文将深入探讨"codegenerate-3.6.1源码",它是基于Jeecg框架的自动生成代码工具的源代码版本...

    Symantec Endpoint Protection Installation Guide English version

    It allows administrators to monitor and control the status of clients, create and distribute policies, and generate reports. **Installation Steps:** 1. **Prerequisites:** Ensure that the server ...

    A Gentle Introduction to ROS .pdf

    1 Introduction 1 In which we introduce ROS, describe how it can be useful, and pre- view the remainder of the book. 2 Getting started 9 In which we install ROS, work with some basic ROS concepts, and ...

    codegenerate-3.6.1

    《深入解析Jeecg框架3.6.1的Codegenerate模块》 Jeecg框架,作为一款高效的企业级快速开发平台,一直以来深受开发者们的青睐。本文将深入剖析Jeecg框架3.6.1版本中的Codegenerate模块,帮助开发者更好地理解和运用...

    Procedural.Content.Generation.for.Cplusplus.Game.Development

    Get to know techniques and approaches to procedurally generate game content in C++ using Simple and Fast Multimedia Library About This Book This book contains a bespoke Simple and Fast Multimedia ...

    IDEA代码生成,Generate POJOs.proovy内容替换

    打开里面的内容,替换idea项目中的Generate POJOs.groovy文件(文件路径:SCratches and Consoles -&gt; extensions -&gt; Database Tools and SQL -&gt; schema - &gt; Generate POJOs.groovy)

    Generate Waveform VI(Labview)

    labview中找不到的generate waveform.vi Generate Waveform .VI程序 目录为activity\Generate Waveform.vi Labview8.5中的Generate Waveform VI labview 8.6中找不到generate waveform vi文件 labview中的一个自带的...

    Android代码-upload-pgyer-plugin

    Pgyer can upload the application to the site, generate installation link and qr code user to open the installation link, or scan code qr code, can start installation. So this plugin can be uploaded to...

    Verilog-generate语句的用法

    1. **Generate-For 语句**:此类型的语句用于循环生成代码块。 2. **Generate-If 语句**:基于条件生成代码块。 3. **Generate-Case 语句**:根据不同的选择生成不同的代码块。 #### 五、Generate-For 语句详解 `...

    MyBatis-Generate

    It will generate code for all versions of MyBatis, and versions of iBATIS after version 2.2.0. It will introspect a database table (or many tables) and will generate artifacts that can be used to ...

    codegenerate-1.0.4.jar

    codegenerate-1.0.4.jar

    Generate POJOs.groovy

    IDEA通过Generate.POJOs.groovy映射数据库自动生成对应的Java实体类, 具体逻辑不详细展示,可参考:https://blog.csdn.net/weixin_40375601/article/details/106807644

    Generate Waveform.vi

    Generate Waveform.vi

    jeecg-mybatis-generate 源码

    1. **数据库元数据获取**:Jeecg-Mybatis-Generate首先连接到指定的数据库,通过JDBC获取表的元数据,包括表名、字段名、数据类型等信息。 2. **模型类生成**:根据数据库中的表信息,生成对应的Java实体类,实体类...

    MybatisGenerate_代码生成_tkMybatis_mybatisgenerate_mybatis_

    1. **配置**:首先,你需要在项目中引入MybatisGenerate的相关依赖,并配置生成代码所需的参数,如数据库连接信息、表名、实体类包路径等。 2. **选择模板**:MybatisGenerate通常提供多种模板供用户选择,不同模板...

    Generate_handwritten_numbers_from_1_to_9_and_make__Generat

    Generate_handwritten_numbers_from_1_to_9_and_make__Generate_handwritten_number

Global site tag (gtag.js) - Google Analytics