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. It means that any string that returns some 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 would be:

{{ 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

Shape FiltersLink

These filters let you create, filter and display shapes.

new_shapeLink

Returns a shape with the specified name as input.

Input

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

shape_stringLink

Renders a shape to a string value.

Input

{{ "DateTime" | new_shape | shape_string }}

Output

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

clear_alternatesLink

Removes any alternates from an input shape.

Input

{{ my_shape | clear_alternates }}

add_alternatesLink

Adds alternates to an input shape.

Input

{{ my_shape | add_alternates: "alternate1 alternate2" }}

clear_classesLink

Removes any classes from an input shape.

Input

{{ my_shape | clear_classes }}

add_classesLink

Adds classes to an input shape.

Input

{{ my_shape | add_classes: "class1 class2" }}

shape_typeLink

Replaces the shape type of an input shape.

Input

{{ my_shape | shape_type: "OtherShapeType" }}

display_typeLink

Replaces the display type of an input shape.

Input

{{ my_shape | display_type: "Summary" }}

shape_positionLink

Replaces the position of an input shape.

Input

{{ my_shape | shape_position: "Content:before" }}

shape_tabLink

Replaces the tab of an input shape. Input

{{ my_shape | shape_tab: "properties" }}

remove_itemLink

Removes a named shape from an input shape items.

Input

{% display Model.Content | remove_item: "BodyPart" %}

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

set_propertiesLink

Replaces a property of an input shape.

{{ Model.Pager | set_properties: next_class: 'next', next_text: '>>' }}

Layout TagsLink

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

displayLink

Renders a shape. Similar to the shape_string filter.

Input

{% assign date_time = "DateTime" | new_shape %}
{% display date_time %}

Output

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

build_displayLink

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

Input

{% display mycontentitem | build_display: "Detail"  %}

shapeLink

Renders a specific named tag with its properties

Input

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

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 {% display Model.Header %} 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 tag helper from the MVC package.

CREDITSLink

FluidLink

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