https://github.com/linux-china/smarty4j
Smarty Template Engine for Java
https://github.com/linux-china/smarty4j
Last synced: 12 months ago
JSON representation
Smarty Template Engine for Java
- Host: GitHub
- URL: https://github.com/linux-china/smarty4j
- Owner: linux-china
- Created: 2011-10-13T06:41:49.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2011-10-19T03:38:18.000Z (over 14 years ago)
- Last Synced: 2025-04-02T02:51:13.853Z (over 1 year ago)
- Language: Java
- Homepage:
- Size: 298 KB
- Stars: 23
- Watchers: 9
- Forks: 19
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Introduction:
Smarty4J is an template engine implemented by Java to deal with Smarty template. For Smarty please visit http://www.smarty.net
## How to Use
### Open your pom.xml and add:
org.lilystudio
smarty4j
1.0.1
### Example:
import junit.framework.TestCase;
import org.lilystudio.smarty4j.Context;
import org.lilystudio.smarty4j.Engine;
import org.lilystudio.smarty4j.Template;
import java.io.ByteArrayOutputStream;
/**
* smarty template test
*/
public class SmartyTemplateTest extends TestCase {
/**
* smarty engine
*/
private Engine smartyEngine = new Engine();
/**
* test to render smarty template
*
* @throws Exception exception
*/
public void testRender() throws Exception {
Template template = smartyEngine.getTemplate("/src/test/resources/demo.tpl");
Context context = new Context();
context.set("title", "欢迎光临!");
ByteArrayOutputStream out = new ByteArrayOutputStream();
template.merge(context, out);
System.out.println(out.toString("utf-8"));
}
}