Commits

Brian Mearns committed 879b308

Added another example template: embedded data.

  • Participants
  • Parent commits 2002f76

Comments (0)

Files changed (2)

File templ/README.templ

             } >>>
         } % end section "Code Generation..."
 
+
+        {section "Embedded Data"
+            <<< {EXAMPLE-TEMPLATE
+                c
+                {implode
+                    <<<
+                    The next example shows how {code templ} allows you to easily embed data
+                    directly in the template file that uses it, allowing you to keep just
+                    one file under version control, for instance.
+                    >>>
+                }
+                "It produces this:"
+                "
+{v
+    %Embedded data
+    {$ :DATA {'
+        %   Name            Year    Month (-1)      Date
+        {'  \"Alan T.\"     1912    05              23 }
+        {'  \"John V.\"     1903    11              28 }
+        {'  \"Claude S.\"   1916    03              30 }
+        {'  \"George B.\"   1815    10              2  }
+        {'  \"George B.\"   1815    10              2  }
+        {'  \"Ada L.\"      1815    11              15 }
+        {'  \"Charles B.\"  1791    11              26 }
+        {'  \"Donald K.\"   1938    0               10 }
+        {'  \"Dennis R.\"   1941    8               9  }
+    }}
+}{for :ROW {$ :DATA} {:
+    {$ :STAMP {stamp {slice 1 {$ :ROW}}}}
+    {$ :NOW {stamp}}
+    {$ :AGE {floor {div {- {$ :NOW} {$ :STAMP}} {* 60 60 24 365.25}}}}
+    {echo {@ 0 {$ :ROW}} \", age \" {$ :AGE} \" years.\" {\\n} }
+}}
+                " } >>>
+        } % end section "Embedded Data"
+
+
+
     }} %end section Examples
 
 }}{#

File templ/tbuiltin.py

             #We use the C style month and doy. Python adds 1 to these.
             xlist[1] += 1   #Month
             del(xlist[6:])
-            print xlist
             return ttypes.String(calendar.timegm(xlist))
 
 @texec.function