From 0e2a6a03d819b624609719d55520e7385922a02f Mon Sep 17 00:00:00 2001 From: Sayi Date: Tue, 29 Dec 2020 15:18:34 +0800 Subject: [PATCH] :palm_tree: Release V1.9.0 --- README.md | 101 ++++++++++-------- pom.xml | 8 +- .../compute/DefaultELRenderDataCompute.java | 4 +- .../render/compute/SpELRenderDataCompute.java | 6 +- 4 files changed, 64 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 98d255f1..a63bf312 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ poi-tl是一种 *"logic-less"* 模板引擎,没有复杂的控制结构和变 > > [《Google CTemplate》](https://github.com/OlafvdSpek/ctemplate/blob/master/doc/guide.html) -poi-tl支持自定义渲染函数(插件),函数可以在Word模板的任何位置执行,在文档的任何地方做任何事情(*Do Anything Anywhere*)是poi-tl的星辰大海。 +poi-tl支持自定义函数(插件),函数可以在Word模板的任何位置执行,在文档的任何地方做任何事情(*Do Anything Anywhere*)是poi-tl的星辰大海。 ## Maven @@ -23,7 +23,7 @@ poi-tl支持自定义渲染函数(插件),函数可以在Word模板的任何 com.deepoove poi-tl - 1.8.2 + 1.9.0 ``` @@ -74,13 +74,16 @@ Word模板: ```json { "watermelon": { - "path": "assets/watermelon.png" + "image": "assets/watermelon.png", + "pictureType" : "PNG" }, "lemon": { - "path": "http://xxx/lemon.png" + "image": "http://xxx/lemon.png", + "pictureType" : "PNG" }, "banana": { - "path": "sob.png", + "image": "sob.png", + "pictureType" : "PNG", "width": 24, "height": 24 } @@ -111,27 +114,34 @@ banana 🍌 数据: ```json { - "song": { - "rows": [ - { - "cells": [ - {"cellText": {"text": "Song name"}}, - {"cellText": {"text": "artist"}} - ] - } - ], - "rows": [ - { - "cells": [ - {"cellText": {"text": "Memories"}}, - {"cellText": {"text": "Maroon 5"}} - ], - "rowStyle":{ - "backgroundColor":"f6f8fa" + "rows": [ + { + "cells": [ + { + "paragraphs": [ + { + "contents": [ + { + "text": "Song name" + } + ] + } + ] + }, + { + "paragraphs": [ + { + "contents": [ + { + "text": "Artist" + } + ] + } + ] } - } - ] - } + ] + } + ] } ``` @@ -145,7 +155,6 @@ Word模板: -
Song nameArtist
MemoriesMaroon 5
### 列表 @@ -154,22 +163,22 @@ Word模板: 数据: ```json { - "feature": { - "numFmt": { - "decimal": "%1)" - }, - "numbers": [ - { - "text": "Plug-in function, define your own function" - }, - { - "text": "Supports text, pictures, table, list, if, foreach..." - }, - { - "text": "Templates, not just templates, but also style templates" - } - ] - } + "format" : { + "lvlText" : "●" + }, + "items" : [ { + "contents" : [ { + "text" : "Plug-in grammar, add new grammar by yourself" + } ] + }, { + "contents" : [ { + "text" : "Supports word text, local pictures, web pictures, table, list, header, footer..." + } ] + }, { + "contents" : [ { + "text" : "Templates, not just templates, but also style templates" + } ] + } ] } ``` @@ -182,9 +191,9 @@ Word模板: 输出: ``` -1) Plug-in function, define your own function -2) Supports text, pictures, table, list, if, foreach... -3) Templates, not just templates, but also style templates +● Plug-in function, define your own function +● Supports text, pictures, table, list, if, foreach... +● Templates, not just templates, but also style templates ``` ### 区块对 @@ -341,7 +350,7 @@ Address: Shanghai,China ## 详细文档与示例 -[中文文档Documentation](http://deepoove.com/poi-tl) [1.9.0-beta文档](http://deepoove.com/poi-tl/1.9.0-beta) +[中文文档Documentation](http://deepoove.com/poi-tl) * [基础(图片、文本、表格、列表)示例:软件说明文档](http://deepoove.com/poi-tl/#_%E8%BD%AF%E4%BB%B6%E8%AF%B4%E6%98%8E%E6%96%87%E6%A1%A3) * [表格示例:付款通知书](http://deepoove.com/poi-tl/#example-table) diff --git a/pom.xml b/pom.xml index dccf5c7a..ee0d02a5 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ com.deepoove poi-tl - 1.9.0-SNAPSHOT + 1.9.0 jar poi-tl @@ -29,6 +29,7 @@ Sayi sayi90@163.com + https://github.com/Sayi @@ -38,15 +39,11 @@ git@github.com:Sayi/poi-tl.git - - UTF-8 true - true - oss @@ -108,7 +105,6 @@ 1.0.50 test - org.junit.jupiter junit-jupiter-api diff --git a/src/main/java/com/deepoove/poi/render/compute/DefaultELRenderDataCompute.java b/src/main/java/com/deepoove/poi/render/compute/DefaultELRenderDataCompute.java index 90ce0c19..e227850d 100644 --- a/src/main/java/com/deepoove/poi/render/compute/DefaultELRenderDataCompute.java +++ b/src/main/java/com/deepoove/poi/render/compute/DefaultELRenderDataCompute.java @@ -31,7 +31,9 @@ public class DefaultELRenderDataCompute implements RenderDataCompute { public DefaultELRenderDataCompute(EnvModel model, boolean isStrict) { this.elObject = DefaultEL.create(model.getRoot()); - this.envObject = DefaultEL.create(model.getEnv()); + if (null != model.getEnv() && !model.getEnv().isEmpty()) { + this.envObject = DefaultEL.create(model.getEnv()); + } this.isStrict = isStrict; } diff --git a/src/main/java/com/deepoove/poi/render/compute/SpELRenderDataCompute.java b/src/main/java/com/deepoove/poi/render/compute/SpELRenderDataCompute.java index 04f1969c..a0d533b4 100644 --- a/src/main/java/com/deepoove/poi/render/compute/SpELRenderDataCompute.java +++ b/src/main/java/com/deepoove/poi/render/compute/SpELRenderDataCompute.java @@ -48,10 +48,12 @@ public SpELRenderDataCompute(EnvModel model, boolean isStrict) { public SpELRenderDataCompute(EnvModel model, boolean isStrict, Map spELFunction) { this.isStrict = isStrict; this.parser = new SpelExpressionParser(); - this.envContext = new StandardEvaluationContext(model.getEnv()); + if (null != model.getEnv() && !model.getEnv().isEmpty()) { + this.envContext = new StandardEvaluationContext(model.getEnv()); + ((StandardEvaluationContext) envContext).addPropertyAccessor(new ReadMapAccessor()); + } this.context = new StandardEvaluationContext(model.getRoot()); ((StandardEvaluationContext) context).addPropertyAccessor(new ReadMapAccessor()); - ((StandardEvaluationContext) envContext).addPropertyAccessor(new ReadMapAccessor()); spELFunction.forEach(((StandardEvaluationContext) context)::registerFunction); }