Commit a6bc3443 authored by Rob Pike's avatar Rob Pike

rewrite template library:

	- separate parsing from execution
	- rearrange code for organizational clarity
	- provide execution errors and parse-time errors
	- implement .or for repeated

TBR=rsc
OCL=27650
CL=27650
parent 8e4b65d0
This diff is collapsed.
...@@ -75,6 +75,13 @@ var tests = []*Test { ...@@ -75,6 +75,13 @@ var tests = []*Test {
&Test{ " {.space} \n", " " }, &Test{ " {.space} \n", " " },
&Test{ " {#comment} \n", "" }, &Test{ " {#comment} \n", "" },
// Variables at top level
&Test{
"{header}={integer}\n",
"Header=77\n"
},
// Section // Section
&Test{ &Test{
"{.section data }\n" "{.section data }\n"
...@@ -152,6 +159,29 @@ var tests = []*Test { ...@@ -152,6 +159,29 @@ var tests = []*Test {
"ItemNumber1=ValueNumber1\n" "ItemNumber1=ValueNumber1\n"
"ItemNumber2=ValueNumber2\n" "ItemNumber2=ValueNumber2\n"
}, },
&Test{
"{.section pdata }\n"
"{.repeated section @ }\n"
"{item}={value}\n"
"{.or}\n"
"this should not appear\n"
"{.end}\n"
"{.end}\n",
"ItemNumber1=ValueNumber1\n"
"ItemNumber2=ValueNumber2\n"
},
&Test{
"{.section @ }\n"
"{.repeated section empty }\n"
"{item}={value}\n"
"{.or}\n"
"this should appear: empty field\n"
"{.end}\n"
"{.end}\n",
"this should appear: empty field\n"
},
// Formatters // Formatters
&Test{ &Test{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment