├── .gitignore ├── README.md ├── SuperSimpleViewEngine.Tests ├── Binaries │ ├── xunit.dll │ └── xunit.extensions.dll ├── FakeViewEngineHost.cs ├── Properties │ └── AssemblyInfo.cs ├── SuperSimpleViewEngine.Tests.csproj └── SuperSimpleViewEngineTests.cs ├── SuperSimpleViewEngine.sln └── SuperSimpleViewEngine ├── IViewEngineHost.cs ├── Properties └── AssemblyInfo.cs ├── SuperSimpleViewEngine.cs └── SuperSimpleViewEngine.csproj /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore file for Visual Studio 2008 2 | 3 | # use glob syntax 4 | syntax: glob 5 | 6 | # Ignore Visual Studio 2008 files 7 | *.csproj.orig 8 | *.obj 9 | *.exe 10 | *.pdb 11 | *.user 12 | *.aps 13 | *.pch 14 | *.vspscc 15 | *_i.c 16 | *_p.c 17 | *.ncb 18 | *.suo 19 | *.tlb 20 | *.tlh 21 | *.bak 22 | *.cache 23 | *.ilk 24 | *.log 25 | *.lib 26 | *.sbr 27 | *.scc 28 | *.cs.orig 29 | [Bb]in 30 | [Db]ebug*/ 31 | obj/ 32 | [Rr]elease*/ 33 | _ReSharper*/ 34 | [Tt]est[Rr]esult* 35 | [Bb]uild[Ll]og.* 36 | *.[Pp]ublish.xml 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Super Simple View Engine 2 | ======================== 3 | 4 | A super simple regex based view engine used in [Nancy](https://github.com/thecodejunkie/Nancy) and (soon to be) [TinyTemplates](https://github.com/grumpydev/TinyTemplates). 5 | 6 | Models can either be standard types, or ExpandoObjects (or any other object implementing IDynamicMetaObjectProvider that implements IDictionary to access its properties). 7 | 8 | Syntax 9 | ------ 10 | 11 | All commands have an optional semi-colon delimiter which can be used to remove ambiguity. Any [.Parameters] parameter can be multiple levels deep (e.g. This.Property.That.Property). 12 | 13 | ### Standard variable substitution 14 | Syntax: @Model[.Parameters] 15 | Example: Hello @Model.Name 16 | Example: Hello @Model.User.Age 17 | 18 | Replaces with the string representation of the parameter, or the model itself if a parameter is not specified. 19 | 20 | ### Iterators 21 | Syntax: @Each[.Parameters] [@Current[.Parameters]] @EndEach 22 | Example: @Each.Users Hello @Current! @EndEach 23 | 24 | Creates one copy of the contents of the @Each per element in the collection and substitutes @Current in the same way as @Model, but bound to the current item in the collection. 25 | 26 | @Current can be used multiple times inside the @Each block. 27 | 28 | ### Conditionals 29 | Syntax: @If[Not].Parameters [contents] @EndIf 30 | Example: @If.HasUsers Users found! @EndIf 31 | Example: @IfNot.HasUsers No users found! @EndIf 32 | 33 | Parameters must be a boolean (see Implicit Conditionals below). Nesting of @If and @IfNot statements is not supported. 34 | 35 | ### Implicit Conditionals 36 | If the model has property that implements ICollection then you can use an implicit conditional. The implicit conditional syntax is the same as a normal conditional, but the Parameters part is set to "Has[CollectionPropertyName]". The conditional will be true if the collection contains items, and false if it does not or if it is null. 37 | 38 | Example: @If.HasUsers Users found! @EndIf 39 | 40 | The above example will expand to "Users found!" if the model has a collection called "Users" and it contains items. 41 | 42 | ### HTML Encoding 43 | Both the @Model and @Current keywords (with or without parameters) can have an optional ! after the @ to HTML encode the output. 44 | 45 | Example: @!Model.Test 46 | 47 | Would HTML encode the output. 48 | 49 | ### Partials 50 | Syntax: @Partial['