• Getting Started
    • Prerequisites
    • Download and Installation
    • Change Log
  • Developer Guide
    • EvenCart Plugins
      • Development Environment Setup
      • Plugin Structure
      • EvenCart MVC
      • Dependency Injection
      • Domain Entities
      • Database Versions
      • Plugin Settings
      • Data Provider Plugin
      • Payment Processing Plugin
      • Shipping Provider Plugin
      • Authentication Provider
      • Widget Plugin
    • EvenCart API
      • Authentication
      • Requests & Responses
      • API EndPoints
    • Caching
  • Designer Guide
    • How to create a theme
    • Extended Tags
      • Layout Tag
      • Widget Tag
      • Json Tag
      • Css Tag
      • Js Tag
      • Bundle Tag
      • Partial Tag
      • Control Tag
      • Route Tag
      • Global Tag
      • Component Tag
    • Extended Filters
    • Global Objects
  • Packaging & Distribution

Extended Filters

Filters allow designers to change the format of data being rendered on the page. In addition to standard liquid filters, EvenCart provides some additional filters that you can use.

Syntax

To apply a filter, following syntax is used.

{{variable | filter_name [: parameter1 : parameter2...]}}

The following additional filters are available in EvenCart

1. t

To render localized string for a text, t filter can be used. The filter translates the string to the current user's localization language if available. If no translation is found, the same string is returned.

Example

{{"Thank you for shopping with us" | t}}

2. pluralize

To render different strings depending on the singularity of provided variable, pluralize filter is used. It expects two strings as parameter. The first parameter is the singular string to be used while second parameter is the plural string to be used.

Example

{% assign count=1 %}
{{count | pluralize : "item" : "items" }}

Output

1 item

3. withCurrency

To render the currency symbol with an amount, withCurrency filter is used. The filter uses culture settings of the current user. If not found, default store culture settings are used.

Example

{% assign amount=100 %}
{{amount | withCurrency }}

Output

$100.00 //if en-US culture is used

4. newLine2Br

To replace new lines with <br/> tags in a string, newLine2Br tag is used.

Example

{{ str | newLine2Br }}

5. scriptJson

To render an object as a javascript variable, scriptJson is used. It requires a parameter to identify the javascript variable name to be used in the output.

Example

{{ obj | scriptJson : variableName }}

Output

<script type="text/javascript">
var variableName = {...} //obj as serialized
</script>

6. absoluteUrl

To render the absolute url for a given relative url, absoluteUrl can be used.

Example

{{ "/about-us" | absoluteUrl}}

Output

http://yourdomain.com/about-us

7. pretty

To render relative time of provided date compared to the current date, pretty filter can be used.

Example

{{ dateObj | pretty }}

Output

5 minutes ago //actual output will depend on the dateObj

8. stripHtml

To remove the html tags from a string, stripHtml filter is used.

Example

{{"I am <b>bold</b> and <i>italic</i>" | stripHtml}}

Output

I am bold and italic
ON THIS PAGE
  • Syntax

Related Pages

  • How to create a theme
  • Extended Tags
  • Global Objects
© 2022 Sojatia Infocrafts Pvt. Ltd. All rights reserved. Powered by onlyDoc.