forked from xianrendzw/EasyReport
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mark.yky
committed
Sep 5, 2018
1 parent
4459d65
commit 01b0230
Showing
14 changed files
with
92 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
easyreport-engine/src/main/java/com/easytoolsoft/easyreport/engine/util/ThymeleafUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.easytoolsoft.easyreport.engine.util; | ||
|
||
import java.util.Map; | ||
import org.thymeleaf.TemplateEngine; | ||
import org.thymeleaf.templatemode.TemplateMode; | ||
import org.thymeleaf.templateresolver.StringTemplateResolver; | ||
|
||
public class ThymeleafUtils { | ||
private static TemplateEngine TEMPLATE_ENGINE = null; | ||
|
||
/** | ||
* 替换的模板中的参数 | ||
* | ||
* @param template | ||
* @param parameters | ||
* @return 替换后的文本 | ||
*/ | ||
public static String parse(final String template, final Map<String, Object> parameters) { | ||
final org.thymeleaf.context.Context ctx = new org.thymeleaf.context.Context(); | ||
ctx.setVariables(parameters); | ||
return getThymeLeafTemplate().process(template, ctx); | ||
} | ||
|
||
public static TemplateEngine getThymeLeafTemplate() { | ||
if (TEMPLATE_ENGINE == null) { | ||
TEMPLATE_ENGINE = new TemplateEngine(); | ||
// Resolver for String | ||
StringTemplateResolver templateResolver = new StringTemplateResolver(); | ||
templateResolver.setTemplateMode(TemplateMode.TEXT); | ||
TEMPLATE_ENGINE.addTemplateResolver(templateResolver); | ||
return TEMPLATE_ENGINE; | ||
} else { | ||
return TEMPLATE_ENGINE; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters