Filters are functions that modify values.
For example, the truncate filter will truncate a string:
{{ 'this is a long string' }} => this is a long string
{{ 'this is a long string' | truncate: 7 }} => this is
Returns a SCRIPT tag with the argument as the source URL to load the javascript code from. Can not be used with inline Javascript code.
Returns a LINK tag referencing the stylesheet given by the URL argument. You can add an additional argument for media like this: {{ ‘print.css’ | asset_url | stylesheet_tag: ‘print’ }}
Pass in the filename of an asset (CSS, image, etc.) in your theme, without the path, and it will return an absolute URL (without the hostname) to the asset. Can be used with script_tag and stylesheet_tag.
Returns an A tag, with the first argument as the link text, the second being the URL, and an optional third being the title. Example:
{{ comment.submit_idea_url | link_to: 'Good idea!', 'Submit this comment as an idea for a new story' }}
would return something like:
<a href="..." title="Submit this comment as an idea for a new story">Good idea!</a>
Returns a link to an object, such as a story, idea, or comment with the title of the object as the link text. Can be used like this: {{ idea.poster | link }}.
Truncates its argument to the number of characters give. Example: {{ story.title | truncate: 30 }}. This is used for strings that don’t include HTML, or where the HTML tags have been properly escaped.
Like truncate, but strips its argument of HTML tags first, and escapes it to make it safe for inclusion in HTML afterwards. This is used for things like the body of a comment or story which contains intentional HTML tags.
Creates a link with an onclick handler that will use Javascript to create a form on-the-fly and submit to the URL using the POST method. This is required for some actions, such as banning users.
HTML-escapes a value, replacing HTML-specific characters like < and > with their HTML-safe equivalents.
Encodes a string for user in a URL parameter.
Returns the singular or plural version, depending on count. Eg. {{ 1 | pluralize: ‘wolf’ }} will return ‘1 wolf’, but {{ 4 | pluralize: ‘wolf’ }} will return ‘4 wolves’. If the automatic pluralization doesn’t work for you, you can pass your own, as in {{ stories_count | pluralize: ‘story’, ‘stories’ }}.
Formats a date using the format specified, which defaults to the site-default date format. For details of the format, see the Ruby documentation for Time#strftime.
Formats a timestamp using the format specified, which defaults to the site-default datetime format. For details of the format, see the Ruby documentation for Time#strftime.
Formats a timestamp using the format specified, which defaults to the site-default time format. For details of the format, see the Ruby documentation for Time#strftime.
Formats a number with thousand-separator, eg. {{ 42350 | thousand_sep }} => “42,350”. You can also supply your own separator if you prefer: {{ 42350 | thousand_sep: ’.’ }} => “42.350”.
Change the string to lowercase.