/
README
31 lines (26 loc) · 1.62 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Welcome to my bizarre attempt to use Template Toolkit templates with .NET. My ultimate goal is to turn this into a ViewEngine for ASP.NET MVC
Rather than writing my own parser/lexer, I'm attempting to use ANTLR as the Parser/Lexer grammer which outputs an AST. The AST is then translated into C# using StringBuilder as part of ANTLR itself. The resulting source is compiled and run.
I chose to use Lexer/Parser->AST->Template assuming that once the grammar is written, we can use the parser to ouput VB.NET or any other language using the appropriate templates.
I'm starting simple (GET/SET) and working may out from there. Something should be easy. Some things fill be harder (FILTER), and some things won't translate at all (PERL blocks).
P.S. I have no clue what I'm doing. Most of this stuff was way over my head when I started, but somehow I have some simple syntac working all the way through the process. :-)
WHAT'S WORKING?
- implicit variable get [% variable %]
- explicit variable get [% GET variable %]
- variable fallback from Process(data) to Settings(variables)
- implicit variable set [% variable = x %], where x is string, number, decimal
- explicit variable set [% SET variable = x %], where x is string, number, decimal
- set defaults [% DEFAULT variable = x %], where x is string, number, decimal
- multiple defaults in one block
[% DEFAULT
foo = 1
bar = 'baz'
baz = 2.34
%]
- multiple sets in one block
[% SET
foo = 1
bar = 'baz'
baz = 2.34
%]
- basic if statement [% IF variable %] [% variable %] [% END %]
- basic foreach statment [% FOREACH i IN variable %] [% i %] [% END %]