url_encode filter
Encode a string to be used in a URL.
Examples
Use the url_encode and url_decode filters to encode strings for use in URLs, and to decode strings that have been url encoded.
{{"liquid filter" | url_encode}}
liquid%20filter
{{"liquid filter" | url_encode:true}}
liquid+filter
{{"liquid%20filter" | url_decode}}
liquid filter
{{"liquid+filter" | url_decode}}
liquid+filter
{{"liquid+filter" | url_decode:true}}
liquid filter
Related
Resolves the URL for an image with the desired presets and other settings applied.
Sets the canonical URL for the current page, which is output by default as part of an HTML page's {{ automatic_markup }}.
url_decode filter
Decode a url encoded string.
Examples
Use the url_encode and url_decode filters to encode strings for use in URLs, and to decode strings that have been url encoded.
{{"liquid filter" | url_encode}}
liquid%20filter
{{"liquid filter" | url_encode:true}}
liquid+filter
{{"liquid%20filter" | url_decode}}
liquid filter
{{"liquid+filter" | url_decode}}
liquid+filter
{{"liquid+filter" | url_decode:true}}
liquid filter
Related
Resolves the URL for an image with the desired presets and other settings applied.
Sets the canonical URL for the current page, which is output by default as part of an HTML page's {{ automatic_markup }}.
base64_url_safe_decode filter
Decodes a string from a URL-safe base64 format. The difference between the base64 and URL-safe base64 formats is that the URL-safe format uses - and _ in place of + and /, which can cause problems when used in a URL.
Examples
Use the base64_encode, base64_decode, base64_url_safe_encode, and base64_url_safe_decode filters to encode and decode strings to and from a base64 format.
{{ '>>> do you want to stop?' | base64_encode }}
Pj4+IGRvIHlvdSB3YW50IHRvIHN0b3A/
{{ 'Pj4+IGRvIHlvdSB3YW50IHRvIHN0b3A/' | base64_decode }}
>>> do you want to stop?
{{ '>>> do you want to stop?' | base64_url_safe_encode }}
Pj4-IGRvIHlvdSB3YW50IHRvIHN0b3A_
{{ 'Pj4-IGRvIHlvdSB3YW50IHRvIHN0b3A_' | base64_url_safe_decode }}
>>> do you want to stop?
Related
Resolves the URL for an image with the desired presets and other settings applied.
Sets the canonical URL for the current page, which is output by default as part of an HTML page's {{ automatic_markup }}.
base64_url_safe_encode filter
Encodes a string to a URL-safe base64 format. The difference between the base64 and URL-safe base64 formats is that the URL-safe format uses - and _ in place of + and /, which can cause problems when used in a URL.
Examples
Use the base64_encode, base64_decode, base64_url_safe_encode, and base64_url_safe_decode filters to encode and decode strings to and from a base64 format.
{{ '>>> do you want to stop?' | base64_encode }}
Pj4+IGRvIHlvdSB3YW50IHRvIHN0b3A/
{{ 'Pj4+IGRvIHlvdSB3YW50IHRvIHN0b3A/' | base64_decode }}
>>> do you want to stop?
{{ '>>> do you want to stop?' | base64_url_safe_encode }}
Pj4-IGRvIHlvdSB3YW50IHRvIHN0b3A_
{{ 'Pj4-IGRvIHlvdSB3YW50IHRvIHN0b3A_' | base64_url_safe_decode }}
>>> do you want to stop?
Related
Resolves the URL for an image with the desired presets and other settings applied.
Sets the canonical URL for the current page, which is output by default as part of an HTML page's {{ automatic_markup }}.
{% set_canonical_url %}
Sets the canonical URL for the current page, which is output by default as part of an HTML page's {{ automatic_markup }}.
The current canonical URL is available at {{ automatic_markup.canonical_url }}
Related
Sets the meta description for the current page, which is output by default as part of an HTML page's {{ automatic_markup }}.
Saves custom properties on the session. Note that this doesn't mean much unless the user (or the developer) has granted permission for sessions.
Resolves the URL for an image with the desired presets and other settings applied.
Sets the default timezone to use when rendering dates and times on the page that do not already have a separate timezone configured.
Sets the Content-Type header for the HTTP response.
Sets the robots meta directive.
Saves custom properties on the client that will survive across multiple sessions until they are changed, unset, or the "session" permission expires. Note that this doesn't mean much unless the user (or the developer) has granted permission for sessions.
Sets the URL to the favicon for the current page, which is output by default as part of an HTML page's {{ automatic_markup }}.
Saves custom values to predefined profile settings that will be accessible whenever the current profile is logged in. Note that this is meaningless unless the user is logged in. Profile settings may include validation, in which case all settings will be validated before being set and any validation error will prevent the setting(s) from being set. Validation errors may optionally be output to a variable.
Replaces a value on the nearest scope where it has already been defined. If it has not been defined yet, it is stored on the root scope.
Sets one or more headers in the HTTP response.
Defines whether the client has granted or deined permission for a particular feature (eg: sessions). The only permission defined by default is the session permission (configurable in the site properties). However, the template developer may use this mechanism for their own purposes as well. The permissions defined by this method will be stored in the permissions cookie, which may be read and/or modified by client-side javascript.
Sets properties on an editable dictionary object. If the dictionary does not exist it will be created and stored on the current scope. If the dictionary exists but is not editable this will throw an error.
Sets a cookie in the HTTP response.
Use the url_encode and url_decode filters to encode strings for use in URLs, and to decode strings that have been url encoded.
{{"liquid filter" | url_encode}}
liquid%20filter
{{"liquid filter" | url_encode:true}}
liquid+filter
{{"liquid%20filter" | url_decode}}
liquid filter
{{"liquid+filter" | url_decode}}
liquid+filter
{{"liquid+filter" | url_decode:true}}
liquid filter
Demonstrates how to use request.query_params for a page with the given query parameters.
{{ request.query_params }}
alpha=abc&beta=b&&emptyvariable&animals=cat&animals=dog&animals=fish
{{ request.query_params.count }}
4
There are 4 distinct query parameters in the URL: alpha, beta, emptyvariable, and animals. Note that the empty query parameter is NOT included in the count.
{{ request.query_params.length }}
7
There are total of 7 query parameters in the URL, including one that does not have a value, one that does not have a key or a value, and one that is repeated three times
{{ request.query_params.alpha }}
abc
The value of the alpha query parameter is abc
{{ request.query_params.emptyvariable }}
The value of the emptyvariable query parameter is empty
{{ request.query_params['animals'] }}
cat,dog,fish
The value of the animals query parameter is a comma-separated list of the values: cat, dog, and fish
{{ request.query_params[1] }}
beta=b
The value of the second query parameter is beta=b
{% if request.query_params has_key 'alpha' %}has alpha{% else %}no alpha{% endif %}
has alpha
The alpha query parameter is present in the URL
{% if request.query_params contains 'animals=cat' %}cat{% else %}no cat{% endif %}
cat
The animals=cat query parameter is present in the URL. Note that the contains condition checks for both the key AND the value of the query parameter.
{% for param in request.query_params %} {% comment %}same as {% for param in request.query_params.by_index %} {% endcomment %}
{% unless forloop.first %}, {% endunless %}{{param}}
{% endfor %}
alpha=abc, beta=b, , emptyvariable, animals=cat, animals=dog, animals=fish
The query parameters can be iterated using a {% for %} loop. Note that this includes empty query parameters that do not have keys or values.
{% for param in request.query_params.keys %}
{% unless forloop.first %}; {% endunless %}{{param}}: {{request.query_params[param]}}
{% endfor %}
alpha: abc; beta: b; emptyvariable: ; animals: cat,dog,fish
The query parameter keys can be iterated using a {% for %} loop. Note that this includes keys that do not have values, but does NOT include query parameters that do not have keys.
Use the base64_encode, base64_decode, base64_url_safe_encode, and base64_url_safe_decode filters to encode and decode strings to and from a base64 format.
{{ '>>> do you want to stop?' | base64_encode }}
Pj4+IGRvIHlvdSB3YW50IHRvIHN0b3A/
{{ 'Pj4+IGRvIHlvdSB3YW50IHRvIHN0b3A/' | base64_decode }}
>>> do you want to stop?
{{ '>>> do you want to stop?' | base64_url_safe_encode }}
Pj4-IGRvIHlvdSB3YW50IHRvIHN0b3A_
{{ 'Pj4-IGRvIHlvdSB3YW50IHRvIHN0b3A_' | base64_url_safe_decode }}
>>> do you want to stop?
Demonstrates how to redirect to requested page with login path appended.
Demonstrates how to create Link with URL field.