From 422b727686ef67aff4c2b86957301c5057db558c Mon Sep 17 00:00:00 2001 From: Christopher Ramey Date: Mon, 13 Feb 2012 02:35:43 +0000 Subject: [PATCH] Finally fixed markdown --- README | 2 + README.md | 120 ++++++++++++++++++++++++------------------------------ 2 files changed, 56 insertions(+), 66 deletions(-) diff --git a/README b/README index e69de29..a318963 100644 --- a/README +++ b/README @@ -0,0 +1,2 @@ +Picotemplate is a BSD-licensed C-Template workalike written in Java. +For usage, please see README.md diff --git a/README.md b/README.md index 03875dc..769f676 100644 --- a/README.md +++ b/README.md @@ -1,114 +1,102 @@ picotemplate ============ -`picotemplate` is a simple, tiny C-Template workalike written in java +picotemplate is a simple, tiny C-Template workalike written in java with the intention of being as high performance as possible. -`picotemplate` is very small, only three class files and is BSD licensed. +picotemplate is very small, only three class files and is BSD licensed. basic usage ----------- First, create your template: -
-
-	
-		This is my template. My favorite food is {{FOOD}}.
-	
-
-
+ + + + This is my template. My favorite food is {{FOOD}}. + + Import the required classes: -
-import com.binarythought.picotemplate.Template;
-import com.binarythought.picotemplate.TemplateDictionary;
-
+ + import com.binarythought.picotemplate.Template; + import com.binarythought.picotemplate.TemplateDictionary; Create your template and template dictionary: -
-Template template = new Template(new File("mytemplate.tpl"));
-TemplateDictionary dict = new TemplateDictionary();
-
+ + Template template = new Template(new File("mytemplate.tpl")); + TemplateDictionary dict = new TemplateDictionary(); Assign a value to the "food" variable (Unassigned variables are not shown): -
-dict.put("food", "cookies");
-
+ + dict.put("food", "cookies"); And parse your template: -
-String result = template.parse(dict);
-
+ + String result = template.parse(dict); And the result: -
-
-	
-		This is my template. My favorite food is cookies.
-	
-
-
+ + + + This is my template. My favorite food is cookies. + + + advanced usage -------------- - picotemplate can selectively show areas of static content, called "sections". It can also loop over these sections using child dictionaries. Consider the following example: -
-
-	
-		{{FAVORITE_SHOW}} is probably my favorite show.
-		{{#GOODSHOWS}}
-		{{SHOW}} is pretty good, too..
-		{{/GOODSHOWS}}
-	
-
-
+ + + + {{FAVORITE_SHOW}} is probably my favorite show. + {{#GOODSHOWS}} + {{SHOW}} is pretty good, too.. + {{/GOODSHOWS}} + + Create your template and template dictionary as usual: -
-Template template = new Template(new File("mytemplate.tpl"));
-TemplateDictionary dict = new TemplateDictionary();
-
+ + Template template = new Template(new File("mytemplate.tpl")); + TemplateDictionary dict = new TemplateDictionary(); Define our favorite show: -
-dict.put("favorite_show", "Happy Days");
-
+ + dict.put("favorite_show", "Happy Days"); Now show the section called "goodshows" (Sections are by default hidden, and must be explicitly told to be shown): -
-dict.show("goodshows");
-
+ + dict.show("goodshows"); And add some shows for it to loop over: -
-TemplateDictionary child1 = dict.createChild("goodshows");
-child1.put("show", "M.A.S.H");
-TemplateDictionary child2 = dict.createChild("goodshows");
-child2.put("show", "A-Team");
-
+ + TemplateDictionary child1 = dict.createChild("goodshows"); + child1.put("show", "M.A.S.H"); + TemplateDictionary child2 = dict.createChild("goodshows"); + child2.put("show", "A-Team"); And the result: -
-
-	
-		Happy Days is probably my favorite show.
 
-		M.A.S.H is pretty good, too..
+    
+      
+        Happy Days is probably my favorite show.
+
+        M.A.S.H is pretty good, too..
 
-		A-Team is pretty good, too..
-	
-
-
+ A-Team is pretty good, too.. + +