Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jlyonsmith/monoliquid
Mono port of the DotLiquid library.
https://github.com/jlyonsmith/monoliquid
Last synced: 6 days ago
JSON representation
Mono port of the DotLiquid library.
- Host: GitHub
- URL: https://github.com/jlyonsmith/monoliquid
- Owner: jlyonsmith
- License: other
- Created: 2012-10-11T18:41:55.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2012-10-11T20:13:03.000Z (about 12 years ago)
- Last Synced: 2023-03-17T16:35:27.460Z (over 1 year ago)
- Language: C#
- Size: 179 KB
- Stars: 3
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE.txt
Awesome Lists containing this project
README
# DotLiquid
### What is this?
DotLiquid is a .NET 3.5 port of the popular [Ruby Liquid templating language](http://www.liquidmarkup.org). It is a separate project that aims to retain the same template syntax as the original, while using .NET coding conventions where possible.
For more information about the original Liquid project, see .
### Quick start
1. Download the latest release from the [downloads page](http://github.com/formosatek/dotliquid/downloads).
The zip file contains DotLiquid.dll, which is the only one you need.
2. Read the [wiki](http://github.com/formosatek/dotliquid/wiki) for information on writing and using
DotLiquid templates.### Why should I use DotLiquid?
* You want to allow your users to edit their own page templates, but want to ensure they don't run insecure code.
* You want to render templates directly from the database
* You want a template engine for emails### What does it look like?
-
{{product.name}}
Only {{product.price | price }}{{product.description | prettyprint | paragraph }}
{% for product in products %}
{% endfor %}
### How to use DotLiquid
DotLiquid supports a very simple API based around the DotLiquid.Template class. Generally, you can read the contents of a file into a template, and then render the template by passing it parameters in the form of a `Hash` object. There are several ways you can construct a `Hash` object, including from a Dictionary, or using the `Hash.FromAnonymousObject` method.
Template template = Template.Parse("hi {{name}}"); // Parses and compiles the template
template.Render(Hash.FromAnonymousObject(new { name = "tobi" })); // => "hi tobi"