Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Lightweight HTML Template Engine

I am after a very lightweight template engine that supports / can be embedded inside Android programs. I've looked at the MiniTemplator (I think that is how you spell it) and that looks great but it loads in only from file and I need to load templates from string and I am not fully confident in changing that code lol.

Can anyone recommend a very lightweight (preferably no jars, single source files etc) that I can use ? I do not need it to parse XML or anything like, just normal HTML files with keywords embedded into them betwee %% tags etc.,

like image 939
Anthoni Gardner Avatar asked Apr 10 '10 07:04

Anthoni Gardner


1 Answers

Chunk is a lightweight template engine that is ideal for Android apps.

The basic {$tag} syntax is straightforward and easy to learn. Chunk also includes advanced features like loops and conditionals when you need more, and comes with some built-in text filters etc.

Templates can be loaded from files or even from a string:

Chunk c = new Chunk();
c.append("Hello {$tags}");
c.set("tags", "glorious tags!");
output = c.toString(); // or c.render( out );

Output:

Hello glorious tags!

With Android in mind, the docs include an extension example that loads templates from a web server, so you can update the templates without having to release a new version of your app.

Confession: I am the author of Chunk - but it's free and open source.

like image 191
Tom McClure Avatar answered Sep 21 '22 15:09

Tom McClure