Skip to content

Commit

Permalink
Merge pull request #4 from mrdaios/feature/render
Browse files Browse the repository at this point in the history
add new render method
  • Loading branch information
mrdaios authored Oct 12, 2024
2 parents 7e568e5 + 31a6e77 commit 191b0dc
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>io.github.mrdaios</groupId>
<artifactId>templates</artifactId>
<packaging>pom</packaging>
<version>0.0.3</version>
<version>0.0.4</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand Down
4 changes: 2 additions & 2 deletions templates-api-freemarker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>io.github.mrdaios</groupId>
<artifactId>templates-api-freemarker</artifactId>
<packaging>jar</packaging>
<version>0.0.3</version>
<version>0.0.4</version>
<name>templates-api-freemarker</name>
<description>templates</description>
<url>https://github.com/mrdaios/templates-maven-plugin</url>
Expand Down Expand Up @@ -57,7 +57,7 @@
<dependency>
<groupId>io.github.mrdaios</groupId>
<artifactId>templates-api</artifactId>
<version>0.0.3</version>
<version>0.0.4</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,24 @@ public Map<String, TemplateRenderModel> render(Map<String, String> template, URL
if (globalTemplateData != null) {
data.put("global", globalTemplateData);
}
return render(template, data);
}

@Override
public Map<String, TemplateRenderModel> render(Map<String, String> template, Map templateData) throws TemplateRenderException {
HashMap<String, TemplateRenderModel> renderModelMap = new HashMap<>();
template.forEach((filePath, templateContent) -> {
// 初始化运行环境
FMRenderContext.getCurrentContext().refreshContext();
Map<String, TemplateRenderModel> result = process(filePath, templateContent, data);
Map<String, TemplateRenderModel> result = process(filePath, templateContent, templateData);
if (null != result && result.size() > 0) {
renderModelMap.putAll(result);
}
});
return renderModelMap;
}


/**
* 加载数据
*
Expand Down
2 changes: 1 addition & 1 deletion templates-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>io.github.mrdaios</groupId>
<artifactId>templates-api</artifactId>
<packaging>jar</packaging>
<version>0.0.3</version>
<version>0.0.4</version>
<name>templates-api</name>
<description>templates</description>
<url>https://github.com/mrdaios/templates-maven-plugin</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ public interface TemplateRenderService {

Map<String, TemplateRenderModel> render(Map<String, String> template, URL templateDataPath, Map globalTemplateData) throws TemplateRenderException;

Map<String, TemplateRenderModel> render(Map<String, String> template, Map templateData) throws TemplateRenderException;

}
4 changes: 2 additions & 2 deletions templates-freemarker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>io.github.mrdaios</groupId>
<artifactId>templates-freemarker</artifactId>
<packaging>jar</packaging>
<version>0.0.3</version>
<version>0.0.4</version>
<name>templates-freemarker</name>
<description>templates</description>
<url>https://github.com/mrdaios/templates-maven-plugin</url>
Expand Down Expand Up @@ -42,7 +42,7 @@
<dependency>
<groupId>io.github.mrdaios</groupId>
<artifactId>templates-api-freemarker</artifactId>
<version>0.0.3</version>
<version>0.0.4</version>
</dependency>
</dependencies>

Expand Down
4 changes: 2 additions & 2 deletions templates-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>io.github.mrdaios</groupId>
<artifactId>templates-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>0.0.3</version>
<version>0.0.4</version>
<name>templates-maven-plugin</name>
<description>templates</description>
<url>https://github.com/mrdaios/templates-maven-plugin</url>
Expand Down Expand Up @@ -69,7 +69,7 @@
<dependency>
<groupId>io.github.mrdaios</groupId>
<artifactId>templates-api</artifactId>
<version>0.0.3</version>
<version>0.0.4</version>
</dependency>
</dependencies>

Expand Down
6 changes: 3 additions & 3 deletions templates-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.github.mrdaios</groupId>
<artifactId>templates</artifactId>
<version>0.0.3</version>
<version>0.0.4</version>
</parent>
<artifactId>templates-test</artifactId>

Expand All @@ -21,12 +21,12 @@
<plugin>
<groupId>io.github.mrdaios</groupId>
<artifactId>templates-maven-plugin</artifactId>
<version>0.0.3</version>
<version>0.0.4</version>
<dependencies>
<dependency>
<groupId>io.github.mrdaios</groupId>
<artifactId>templates-freemarker</artifactId>
<version>0.0.3</version>
<version>0.0.4</version>
</dependency>
</dependencies>
<configuration>
Expand Down

0 comments on commit 191b0dc

Please sign in to comment.