Commits

Joe Bogner committed 395c984

add readme and fix some breaking things

Comments (0)

Files changed (1)

+# picostache.l Tiny mustache template implementation
+# (c) 2012 Joe Bogner 
+# https://bitbucket.org/joebo/picostache/
+
 (default *DELIM_S (chop "{{") *DELIM_E (chop "}}"))
 
 (de context (View Key)
-    (if (= Key ".")
-        View
-        (cdr (assoc Key View)) ) )
+    (setq Func (cdr (assoc Key Model)))
+    (if (pair (fun? Func))
+        (Func View)
+        (if (= Key ".")
+            View
+            (cdr (assoc Key View)) ) ) )
 
 (de section (View Key Rest Inverted)
-    (setq Func (context Model Key))
-    (if (fun? Func)
+    (setq Func (cdr (assoc Key Model)))
+    (if (pair (fun? Func))
         (link (Func (pack (make (render View Rest)))))
         (setq Subview (context View Key))
-        (if (and Inverted (not Subview)) 
-            (render X Rest)
-            (for X Subview (render X Rest)))))
+        (ifn Inverted 
+            (for X Subview (render X Rest))
+            (if (not Subview) (render X Rest) ))))
 
 (de render (View Tree)
     (for X Tree 
     (setq Names '(names . ("joe" "bob" "frank")))
     (push 'Model Names)
     (push 'Model (cons "Upper" '((X) (uppc X))))
-    (test "hello joe^Jnothing here^J - JOE^J - BOB^J - FRANK^J" (renderTree Model Tree)) ) 
+    (test "hello joe^Jnothing here^J - JOE^J - BOB^J - FRANK^J" (renderTree Model Tree)) 
+) 
 
 
-(testRender)
-(testParse)
+# (testRender)
+# (testParse)