Skip to content

jackywcw/smarty4j

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 

Repository files navigation

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:

<dependency>
     <groupId>org.lilystudio</groupId>
     <artifactId>smarty4j</artifactId>
     <version>1.0.1</version>
</dependency>

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"));
        }
    }

About

Smarty Template Engine for Java

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%