Salla Docs
Merchant API
  • Merchant API
  • Salla OAuth 2.0
Partner APIs
  • App API
  • Shipment API
Storefront
  • Twilight Engine
  • Twilight SDK
  • Web Components
  • Change Log
Salla CLI
Merchant API
  • Merchant API
  • Salla OAuth 2.0
Partner APIs
  • App API
  • Shipment API
Storefront
  • Twilight Engine
  • Twilight SDK
  • Web Components
  • Change Log
Salla CLI
Salla - Opensource
Salla - Developers Community
  1. Twig Template Engine
  • Getting Started
    • Create a theme
    • Develop a theme
    • Setup a theme
    • Publish a theme
  • Requirements & Review
    • Overview
    • Main Requirements
    • Review Process
      • UI / UX Review
      • Technical Review
      • Metadata Review
      • Pre-Launch Review
  • Files and Folders Structure
    • Directory structure
    • Twilight.json
  • Twig Template Engine
    • Basic syntax
    • Twilight flavoured twig
  • Theme Architecture
    • Layouts
      • Overview
      • Master Layout
      • Global Variables
      • CSS Variables
      • Salla Icons
      • Custom Fonts
      • Hooks
      • Localizations
    • Pages
      • Overview
      • Home Page
      • Product Pages
        • Products listing
        • Single product
      • Customer Pages
        • Profile
        • Orders list
        • Order details
        • Wishlist
        • Notifications
      • Blog Pages
        • Blog listing
        • Single blog
      • Brand Pages
        • Brands listing
        • Single brand
      • Common Pages
        • Cart
        • Loyalty
        • Thank you
        • Single page
        • Landing Page
    • Componenets
      • Overview
      • Home Components
        • Youtube
        • Fixed banner
        • Testimonials
        • Parallax background
        • Photos slider
        • Store features
        • Square photos
        • Fixed products
        • Products slider
        • Featured products - Style 1
        • Featured Products - Style 2
        • Featured Products - Style 3
        • Brands
        • Enhanced Square Banners
        • Main Links
        • Enhanced Slider
        • Slider Products with Headers
        • Latest Products
        • Vertical Menu with Slider
      • Product Components
        • Essentials
        • Options
      • Common Components
        • Header Components
        • Footer Components
        • Comments component
  • Change Log
  1. Twig Template Engine

Twilight flavoured twig

Although Twig already provides a large list of helper functions and filters, Twilight also has added a selection of useful helpers and filters to make theming easier.
Note
Twig helper functions are called directly with any parameters passed in via parenthesis.

📙 What you'll learn#

In this article, you'll learn how to use:
Twilight flavoured helper functions.
Twilight flavoured filter.

Helpers#

In general, helpers are Twig functions by which we can implement functionality in Twig.
Following are the helper functions available on all Twilight .twig files.
Helper AvailableDescription
is_current_urlChecks the link.
is_pageDisplays the page name.
linkCreates links.
oldKeeps previous inputs.
pluralizeTransforms the word into singular or plural forms.
pageCreates a link to the page.
transTranslates texts to the current store language.

is_current_url#

Checks if the current link matches the passed pattern.
Examples:

is_page#

This helper displays the page name on the page.
Example:

link#

Combine strings to generate a full link.
Examples:

pluralize#

Similar to trans, it takes a $count argument to change the message in plural or singular form in-store language.
Examples:

page#

This helper generates the link to a specific page as follows:
Example
The generated link will be the cart's page url for the store, as follows:
https://www.my-store.com/cart

old#

This helper function keeps previous input from one request during the next request. This feature is particularly useful for re-populating forms after detecting validation errors.
Examples:
Example

trans#

This helper translates the passed key to the current store langauge.
Here are more information about Localization.
Examples:

Filters#

These special filters are available on all .twig files. Use the the pipe sign, |, to use them.
Following are the filters available by Twilight.
Filters AvailableDescription
assetCreates links to Salla's theme files.
camel_caseReplaces punctations and spaces with letters in uppercase.
cdnRetrives links of pre-defined files such as font and saicon.
currencyAdds currency sign.
dateDisplays the dates in the current page language.
is_placeholderChecks if image url is placeholder or image.
kebab_caseReplaces the spaces with a dash.
moneyAn alias for currency filter.
numberParses numbers into Arabic numbers.
snake_caseReplaces spaces in texts with underscore and keeps first letter in lowercase.
studly_caseCapilaizes first letters in each subword.
time_agoShows the time of and action execution.

asset#

This filter creates links to Salla theme files.

camel_case#

This filter removes each spaces or punctuation in a given string, indicating the separation of words with a single capitalized letter, and the first word starting with either case. Common examples include "iPhone" and "eBay".

cdn#

This filter retrives links of pre-defined files such as font and saicon.

currency#

This filter add the currency sign 'SAR' to the passed value.

date#

This filter overrides the default date filter given with Twig. It formats a date to a given format with concidering the page's selected language.

is_placeholder#

This filter is used to know if the image url is placeholder or actual image
Tip
We have default placeholder image, developer may want to use another image, it can be replaced by calling:

kebab_case#

This filter replaces the spaces between words with a dash.

money#

This an alias for currency filter.

number#

This filter will always parse any number given to Arabic number if merchants enables it and the current language is Arabic. It will also parse decimal number representation to a decimal point in Arabic (,)

snake_case#

This filter replaces each space in a given string with an underscore character, and the first letter of each word written in lowercase.

studly_case#

Also known as PascalCase, which implies that the first capital of each subword is capitalized.

time_ago#

This filter shows the time of and action execution, for example, "Comment created 10 minutes ago."
Modified at 2025-03-04 12:54:02
Previous
Basic syntax
Next
Theme Architecture