forked from dotliquid/dotliquid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormatting.cshtml
More file actions
62 lines (43 loc) · 2.13 KB
/
Formatting.cshtml
File metadata and controls
62 lines (43 loc) · 2.13 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
@{
ViewBag.IncludePrism = true;
}
<div id="docs-content">
<markdown>
# Formatting
DotLiquid is intended to be as compatible as possible with the original Liquid syntax. With this in mind, we don't maintain our own template syntax documentation page; we refer you to the original [Liquid for designers](http://github.com/Shopify/liquid/wiki/Liquid-for-Designers) Liquid GitHub page, **but strongly recommend you review the notes below before proceeding**:
<http://github.com/Shopify/liquid/wiki/Liquid-for-Designers>
Any (known!) differences between DotLiquid and Liquid template syntax are noted below.
## Line breaks
To suppress the line break that would normally follow the end of a tag, you can use a hyphen ("-") just before closing the tag. For example:
``` html
<ul>
{% for item in user.tasks -%}
<li>{{ item.name }}</li>
{% endfor -%}
</ul>
```
will result in the following output, without extra line breaks:
``` html
<ul>
<li>Documentation</li>
<li>Code comments</li>
</ul>
```
## Date format strings
When using the `date` filter, DotLiquid supports both Ruby and .NET date format strings (but not both at the same time). By default, it will use .NET date format strings. This can be changed by setting a configuration property:
``` csharp
Liquid.UseRubyDateFormat = true;
```
.NET Format strings can be found here:
<http://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx>
Using a .NET date format string within a template: `{{ SomeDateField | date:"MMMM dd, yyyy" }}`
## Filter and Output Casing
Liquid by default uses Ruby casing for output fields and filters such as `{{ some_field | escape }}`. DotLiquid uses this same convention by default, but can also be changed to use C# naming convention, in which case output fields and filters would be referenced like so `{{ SomeField | Escape }}`
## Includes
You can include a partial template with this tag: `{% include "partial_template" %}`
By naming convention this will find the `_partial_template.liquid` file in the directory specified with:
``` csharp
Template.FileSystem = new LocalFileSystem(root); // root needs to be an absolute path
```
</markdown>
</div>