Stencil is a template engine for .NET (Microsoft and Mono runtimes)
Mission
Stencils goal is to provide a simple, and flexible templating solution for C#. There
are currently very few options, and the ones that are available do not provide a
syntax that we feel is consistent. Stencil does.
Stencil is almost feature complete. It has 95% features implemented, and all additional features occurr on a
project by project basis, which is when Stencil really shines. Stencil built-in directives are constructed in
the same way as any third party directive would need to be coded, thus providing an easy way for users to add
template directives. Once 100% complete, new features can be added to stencil via new directives, rather than
having to add features to the parser itself.
High Level Features
- A simple language
- Enough built-in directives to not need to write your own
- If you need/want to create directives, it is easy
- Runs on Microsoft .NET and Mono
Assumptions
- Stencil will be written using Visual C# Express, however will compile on Mono/.NET 1.0/1.1
- Requests to change/add features to the engine that require modifications to the lexer/parser will only occurr in special cases
-
Related resources
- String Template inspired us to create Stencil
- Contributors will not be actively recruited. Stencil is a small project, and us such, can be managed and developed by one person for now
Example Syntax
If you are at all familiar with smalltalk, the keyword directive syntax will be instantly recognisable. Here is an example template:
Hello #user.Name#, you were born in #user.BirthYear# which makes you #user.Age#
You are a member of the following mailing lists:
<ul>#each: user.Subscriptions do: [
<li>#ea.Name# (#ea.Members#)</li> ]#
</ul>
The template uses a single built in directive, #each:do: which takes an IEnumerable object, and an anonymous template which is declared inline. More to follow.