FormHelpers filters

error_class filter

(up)

Outputs error class if argument is not empty. Example: Using error_class to show output an error class.

<input class="{{ form.errors.description | error_class }}" />

inline_errors filter

(up)

Outputs error fields inline in paragraph. Example: Using inline_errors to show errors inline.

{{ form.errors.description | inline_errors }}

ParamFilter filters

to_param filter

(up)

Converts a supplied drop to URL parameter if possible. Example: Using to_param filter in liquid.

<h1>Signup to a service</h1>
<a href="{{ urls.signup }}?{{ service | to_param }}">Signup to {{ service.name }}</a>

Common filters

group_by filter

(up)

Group collection by some key. Example: Group applications by service.

{% assign grouped = applications | group_by: 'service' %}
{% for group in grouped %}
  Service: {{ group[0 }}
  {% for app in group[1] %}
    Application: {{ app.name }}
  {% endfor %}
{% endfor %}

any filter

(up)

True if any string in the collection equals to the parameter. Example: Are there any pending apps of the current account?

{% assign has_pending_apps = current_account.applications | map: 'state' | any: 'live' %}

stylesheet_link_tag filter

(up)

Stylesheet link

javascript_include_tag filter

(up)

Javascript include tag

image_tag filter

(up)

Image tag

mail_to filter

(up)

Converts email address to a 'mailto' link.

{{ 'me@there.is' | mail_to }}
# => <a href="mailto:me@there.is">me@there.is</a>

html_safe filter

(up)

Marks content as HTML safe so that it is not escaped.

pluralize filter

(up)

Convert word to plural form

delete_button filter

(up)

Generates a button to delete a resource present on the URL. First parameter is a URL, second is a title.

{{ 'Delete Message' | delete_button: message.url }}

delete_button_ajax filter

(up)

Generates a button to delete a resource present on the URL using AJAX. First parameter is a URL, second is a title.

{{ 'Delete Message' | delete_button_ajax: message.url }}

update_button filter

(up)

Generates a button to update a resource present on the URL. First parameter is a URL, second is a title.

{{ 'Update Message' | update_button: message.url }}

create_button filter

(up)

Generates a button to create a resource present on the URL. First parameter is a URL, second is a title.

{{ 'Create Message' | create_button: message.url }}

create_button_ajax filter

(up)

regenerate_oauth_secret_button filter

(up)

link_to filter

(up)

Create link from given text.

{{ "See your App keys" | link_to:'/my-app-keys' }}