JustTE4J - Java Web Template Engine
JustTE4J is a web template engine written in Java. It's core is based on JSoup HTML Parser and servlets. Therefore requires servlet container (preferably Tomcat). In general in consist of one servlet for handling data processing, JustTE4J library (one file) and dependencies.
Case study
Below is a list of case studies.
1. Start up scenario
You have got static page consisting of one html file (index.html) along with css and js folders. You would like to have couple of additional pages like contact.html, items.html and price.html. Index.html file does not have reference to any other page so menu will be needed. Each of these pages would have different title and content, but common header, footer, menu etc. You don't want to copy index.html and replace html data manually.
Solution.
Configure template engine. Copy index.html to /template/form folder and rename to templateTE4J.html. Delete index.html. Do not copy css and js folders. Leave them in main folder. Create four files in /template/data folder - this is: index.ted, contact.ted, items.ted and price.ted.
Edit index.ted file and put the following lines
T:C:I:title:!=Start;
I:C:I:content:!=<div>Welcome </div>;
T:C:P:body:!= <ul class="menuTag">
<li id="pageIndex" class="selectOption"><a href="/index.html">INDEX</a></li>
<li id="pageContact"><a href="/contact.html">Contact</a></li>
<li id="pageItems"><a href="/items.html">Items</a></li>
<li id="pagePrices"><a href="/price.html">Prices</a></li>
</ul>;
Edit contact.ted, items.ted and price.ted in the above mentioned manner. Start server and view index.html file. It's title should be Start. It should contain new element - menu with reference to other pages. It should have new content - Welcome.
2. Reference scenario
Start up scenario but index.html has already menu with reference to other pages. Every page needs to update this menu.
Solution.
Create three files in /template/data folder: contact.ted, items.ted and price.ted. Don't delete index.html.
Edit contact.ted file and put the following lines
T:C:I:title:!=Contact;
I:C:I:content:!=<div>Welcome </div>;
I:A:D:pageIndex:class!=NA;
I:A:I:pageA:class:!=selectOption;
Edit items.ted and price.ted in the above mentioned manner. Start server and view contact.html file. It's title should be Contact. It should contain element - menu with reference to other pages. It should have new content - Welcome.
3. Warning scenario
You have already set up template engine with a couple of pages. All you want is to place Warning information at the top of every page.
Solution.
Edit every .ted file and put the following line:
T:C:P:body:!=<div>Warning</div>
4. Style change
You want to replace every class (value "oldClass" along with other classes) with new value "newClass".
Solution
Edit every .ted file and put the following line:
C:A:I:oldClass:!=newClass;