https://github.com/nagilum/tempy
C# Template Engine
https://github.com/nagilum/tempy
Last synced: 3 months ago
JSON representation
C# Template Engine
- Host: GitHub
- URL: https://github.com/nagilum/tempy
- Owner: nagilum
- Created: 2017-06-16T12:40:50.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-19T11:34:59.000Z (almost 8 years ago)
- Last Synced: 2025-01-16T13:46:55.675Z (4 months ago)
- Language: HTML
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Tempy
## Layout
### Settings
Example
```html
{! layout|post !}
```This will load the post layout file and put content into ```{{ content }}```.
This is registered through the ```.RegisterLayout()``` function.## Template Content and Loops
### Single Variable
Example
```html{{ var|name }}
```Will produce
```htmlPeter
```### Indexed Variable
Example
```html{{ var|names|2 }}
```Will produce
```htmlMolly
```### Function Call
Example
```html{{ func|getName }}
```Will produce
```htmlPeter
```### Function Call with Parameters
Example
```html{{ func|getNameAndAge|"Peter",37 }}
```Will produce
```htmlPeter, 37
```### Function Call with Parameters, using Reflection
Example
```html{{ func|getNameAndAge|"Peter",37 }}
```Will produce
```htmlPeter, 37
```### Check if Variable Exists
Example
```html{% if name %}Hi {{ var|name }}{% end %}
```Will produce
```htmlPeter
```### Check if Multiple Variables Exists
Example
```html{% if name and age %}Hi {{ var|name }}, {{ var|age }}{% end %}
```Will produce
```
```### Reverse If-Check
Example
```html{% if not name %}Something something darkside..{% end %}
```Will produce
```htmlSomething something darkside..
```### Check if Variable is Equal to Something
Example
```html{% if name == "Peter" %}Hi Peter{% end %}
```Will produce
```htmlPeter
```### Check if Multiple Variables are Equal to Something
Example
```html{% if name == "Peter" and age == 37 %}Hi Peter{% end %}
```Will produce
```htmlPeter
``````html
{% if name == "Peter" or age == 37 %}Hi Peter{% end %}
```Will produce
```htmlPeter
```### Reverse If-Check
Example
```html{% if name not "Peter" %}Where did Peter go?{% end %}
```Will produce
```htmlWhere did Peter go?
```### If and Else
Example
```html{% if name %}Variable exists and is {{ var|name }}{% else %}Variable does not exists{% end %}
```Will produce
```htmlPeter
```### Do a Loop
Example
```html
- {{ var|%index }}
{% loop people %}
{% end %}
```
Will produce
```html
- Peter
- Parker
- Molly
```
### Do a Fixed Loop
Example
```html
- {{ var|name }}
{% loop people steps 0,1 %}
{% end %}
```
Will produce
```html
- Peter
- Parker
```
### Do a Nested Loop
Example
```html
{% if companies %}
- {% end %}
-
{{ var|name }}
{% if people %}- {% end %}
- {{ var|%index }}
{% loop people %}
{% end %}
{% if people %}
{% loop companies %}
{% end %}
{% if companies %}
```
Will produce
```html
-
Microsoft
- Peter
- Parker
-
Apple
- Molly
- Holly
```
## Template Functions
### Count
Example
```html
{% if count(members) > 1 %}More than one member!{% end %}
```