Liquid (OrchardCore.Liquid)Link

This module provides a way to create templates securely from the admin site. For more information about the Liquid syntax, please refer to this site: https://shopify.github.io/liquid/

General conceptsLink

HTML escapingLink

All outputs are encoded into HTML by default. This means that any HTML reserved chars will be converted to the corresponding HTML entities. If you need to render some raw HTML chars you can use the Raw filter.

Content Item FiltersLink

All the default filters that are available in the standard Liquid syntax are available in OrchardCore. On top of that each Orchard module can provide custom filters for their own purpose. Here is a list of common filters that apply to content items.

display_urlLink

Returns the URL of the content item

Input

{{ Model.ContentItem | display_url }}

Output

/blog/my-blog-post

display_textLink

Returns the title of the content item

Input

{{ Model.ContentItem | display_text }}

Output

My Blog Post

slugifyLink

Convert a text into a string that can be used in a URL.

Input

{{ "This is some text" | slugify }}

Output

this-is-some-text

containerLink

Returns the container content item of another content item.

Input

{{ Model.ContentItem | container | display_text }}

In this example we assume ContentItem represents a blog post.

Output

Blog

localLink

Converts a UTC date and time to the local date and time based on the site settings.

Input

{{ "now" | local | date: "%c" }}

or

{{ Model.ContentItem.CreatedUtc | local | date: "%c" }}

Output

Wednesday, 02 August 2017 11:54:48

tLink

Localizes a string using the current culture.

Input

{{ "Hello!" | t }}

Output

Bonjour!

html_classLink

Converts a string into a friendly HTML class.

Input

{{ "LandingPage" | html_class }}

Output

landing-page

MarkdownifyLink

Converts a Markdown string to HTML.

Input

{{ "### Services" | markdownify }}

Output

<h3>Services</h3>

PropertiesLink

By default the liquid templates have access to a common set of objects.

Model.ContentLink

When available, a zone shape that contains all the shapes generated by the content's parts and fields.

Model.ContentItemLink

When available, represents the current content item being rendered.

The following properties are available on the ContentItem object.

Property Example Description
Id 12 The id of the document in the database
ContentItemId 4qs7mv9xc4ttg5ktm61qj9dy5d The common identifier of all versions of the content item
ContentItemVersionId 4jp895achc3hj1qy7xq8f10nmv The unique identifier of the content item version
Number 6 The version number
Owner admin The username of the creator of this content item
Author admin The username of the editor of this version
Published true Whether this content item version is published or not
Latest true Whether this content item version is the latest of the content item
ContentType BlogPost The content type
CreatedUtc 2017-05-25 00:27:22.647 When the content item was first created or first published
ModifiedUtc 2017-05-25 00:27:22.647 When the content item version was created
PublishedUtc 2017-05-25 00:27:22.647 When the content item was last published
Content { ... } A document containing all the content properties. See specific documentation for usage .

Content propertyLink

The Content property of a content item exposes all its elements, like parts and fields. It is possible to inspect all the available properties by evaluating Content directly. It will then render the full document.

The convention is that each Part is exposed by its name as the first level. If the content item has custom fields, they will be available under a part whose name will match the content type.

For example, assuming the type Product has a Text field named Size, access the value of this field for a content item as follows:

{{ Model.ContentItem.Content.Product.Size.Text }}

Similarly, if the content item has a Title part, we can access it like this:

{{ Model.ContentItem.Content.TitlePart.Title }}

UserLink

Represents the authenticated user for the current request.

The following properties are available on the User object.

Property Example Description
Identity.Name admin The name of the authenticated user

SiteLink

Gives access to the current site settings, e.g Site.SiteName.

Property Example Description
BaseUrl The base URL of the site
Calendar The site's calendar
Culture en-us The site's culture as an ISO language code
MaxPagedCount 0 The maximum number of pages that can be paged
MaxPageSize 100 The maximum page size that can be set by a user
PageSize 10 The default page size of lists
SiteName My Site The friendly name of the site
SuperUser admin The user name of the site's super user
TimeZoneId America/Los_Angeles The site's time zone id as per the tz database, c.f., https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
UseCdn false Enable/disable the use of a CDN

RequestLink

Represents the current request.

The following properties are available on the Request object.

Property Example Description
QueryString ?sort=name&page=1 The query string
ContentType application/x-www-form-urlencoded; charset=UTF-8 The Content-Type header
ContentLength 600 The Content-Length header
Cookies Usage: Request.Cookies.orchauth_Default The collection of cookies for this request
Headers Usage: Request.Headers.accept The request headers
Query Usage: Request.Query.sort The query value collection parsed from QueryString
Form Usage: Request.Form.value The collection of form values
Protocol https The protocol of this request
Path /OrchardCore.ContentPreview/Preview/Render The path of the request, unescaped
PathBase /mytenant The base path of the request, unescaped
Host localhost:44300 The Host header. May contain the port
IsHttps true True if the scheme of the request is https
Scheme https The scheme of the request
Method GET The HTTP method

Shape FiltersLink

These filters let you create and filter shapes.

shape_newLink

Returns a shape with the specified name as input.

Input

{% assign date_time = "DateTime" | shape_new %}

shape_renderLink

Renders a shape.

Input

{{ Model.Content | shape_render }}

shape_stringifyLink

Converts a shape to its string representation. Contrary to shape_render the result of this filter will be encoded if rendered in the output.

Input

{{ "DateTime" | shape_new | shape_stringify }}

Output

Monday, September 11, 2017 3:29:26 PM

Layout TagsLink

layoutLink

Sets the layout of a view.

Input

{% layout "CustomLayout" %}

Internally an alternate is added to the current theme Layout shape.

render_bodyLink

In a layout, renders the body of the current view.

Input

{% render_body %}

render_sectionLink

In a layout, renders the section with the specified name.

Input

{% render_section "Header", required: false %}

page_titleLink

Alters and renders the title of the current page.

Input

{% page_title Site.SiteName, position: "before", separator: " - " %}

The default parameter is a text that is appended to the current value of the title. position is where the value is appended, in this example at the beginning. separator is a string that is used to separate all the fragments of the title.

Shape TagsLink

shape_clear_alternatesLink

Removes any alternates from a shape.

Input

{% shape_clear_alternates my_shape %}

shape_add_alternatesLink

Adds alternates to a shape.

Input

{% shape_add_alternates my_shape "alternate1", "alternate2" %}
{% shape_add_alternates my_shape "alternate1 alternate2" %}

shape_clear_wrappersLink

Removes any wrappers from a shape.

Input

{% shape_clear_wrappers my_shape %}

shape_add_wrappersLink

Adds wrappers to a shape.

Input

{% shape_add_wrappers my_shape "wrapper1", "wrapper2" %}
{% shape_add_wrappers my_shape "wrapper1 wrapper2" %}

shape_clear_classesLink

Removes any classes from a shape.

Input

{% shape_clear_classes my_shape %}

shape_add_classesLink

Adds classes to a shape.

Input

{% shape_add_classes my_shape "class1 class2" %}
{% shape_add_classes my_shape "class1", "class2" %}

shape_clear_attributesLink

Removes any attributes from a shape.

Input

{% shape_clear_attributes my_shape %}

shape_add_attributesLink

Adds attributes to a shape.

Input

{% shape_add_attributes my_shape attr_name1: "value1", attr_name2: "value2" ... %}

shape_typeLink

Sets the type of a shape.

Input

{% shape_type my_shape "MyType" %}

Whenever the type is changed, it is recommended to clear the shape alternates before using the shape_clear_alternates tag.

shape_display_typeLink

Sets the display type of a shape.

Input

{% shape_display_type my_shape "Summary" %}

Whenever the display type is changed, it is recommended to clear the shape alternates before.

shape_positionLink

Sets the position of a shape.

Input

{% shape_position my_shape "Content:before" %}

shape_tabLink

Sets the tab of a shape.

Input

{% shape_tab my_shape "properties" %}

shape_remove_itemLink

Removes a shape by its name in a Zone.

Input

{% shape_remove_item Model.Content "HtmlBodyPart" %}
{{ Model.Content | shape_render }}

In this example, the Model.Content property evaluates to a zone shape, typically from a Content Item shape template, which contains the HtmlBodyPart shape rendered for the Body Part element. This call will remove the specific shape named HtmlBodyPart.

shape_pagerLink

Replaces the properties of a Pager shape.

Input

{% shape_pager Model.Pager next_class: 'next', next_text: '>>' %}

shape_build_displayLink

Creates the display shape for a content item. It can be used in conjunction with shape_render to render a content item.

Input

{{ mycontentitem | shape_build_display: "Detail" | shape_render }}

shapeLink

Renders a specific named tag with its properties

Input

{% shape "menu", alias: "alias:main-menu", cache_id: "main-menu", cache_expires_after: "00:05:00", cache_tag: "alias:main-menu" %}

When using the shape tag a specific wrapper and / or alternate can be specified.

{% shape "menu", alias: "alias:main-menu", alternate: "Menu_Footer" %}

zoneLink

Renders some HTML content in the specified zone.

Input

{% zone "Header" %}
    <!-- some content goes here -->
{% endzone %}

The content of this block can then be reused from the Layout using the {{ Model.Header | shape_render }} code.

Tag Helper tagsLink

ASP.NET Core MVC provides a set of tag helpers to render predefined HTML outputs. The Liquid module provides a way to call into these Tag Helpers using custom liquid tags.

Invokes the link tag helper from the Orchard.ResourceManagement package.

metaLink

Invokes the meta tag helper from the Orchard.ResourceManagement package.

resourcesLink

Invokes the resources tag helper from the Orchard.ResourceManagement package.

scriptLink

Invokes the script tag helper from the Orchard.ResourceManagement package.

styleLink

Invokes the style tag helper from the Orchard.ResourceManagement package.

aLink

Invokes the a content link tag helper from the OrchardCore.Contents package.

antiforgerytokenLink

Renders a <hidden> element (antiforgery token) that will be validated when the containing <form> is submitted.

Example

{% antiforgerytoken %}

CREDITSLink

FluidLink

https://github.com/sebastienros/fluid
Copyright (c) 2017 Sebastien Ros
MIT License