====== Liquid Filters ====== [[Liquid templates]] are constructed with Liquid drops and filters ("output") and tags. These are the Liquid filters available in SandwichBoard used to manipulate output. ====== Link Liquid Filters ====== ===== path_for_size(image_path, size = nil) ===== Converts an image path to the appropriate path for a given size: 'small', 'medium', 'thumbnail', or 'tiny'. Example: {{ my_image.path | path_for_size: 'thumb' }} ===== stylesheet(stylesheet, media = nil) ===== Creates a link to a Cascading Style Sheet. SandwichBoard already hosts [[http://www.crucialwebhost.com/blog/master-stylesheet-the-most-useful-css-technique/|Crucial's Master Stylesheet]] (''master.css'') and [[http://www.huddletogether.com/projects/lightbox2/|Lightbox]] (''lightbox.css'') on its servers, which you can use without having to upload yourself. Just reference the appropriate style sheet file(s) using the stylesheet filter. Example: {{ 'site' | stylesheet }} {{ 'page' | stylesheet }} {{ 'print' | stylesheet: 'print' }} {{ 'lightbox' | stylesheet }} ===== javascript(javascript) ===== Creates a link to a JavaScript source file. SandwichBoard already hosts [[http://www.prototypejs.org/|Prototype]] (''prototype.js''); [[http://script.aculo.us/|script.aculo.us]] (''builder.js'', ''controls.js'', ''dragdrop.js'', ''effects.js'', ''scriptaculous.js''); and [[http://www.huddletogether.com/projects/lightbox2/|Lightbox]] (''lightbox.js'') on its servers, which you can use without having to upload yourself. Just reference the appropriate JavaScript file(s) using the javascript filter. {{ 'prototype' | javascript }} {{ 'effects' | javascript }} {{ 'lightbox' | javascript }} ====== Text Liquid Filters ====== ===== downcase(input) ===== Converts an input string to downcase. ===== upcase(input) ===== Converts an input string to UPPERCASE. ===== capitalize(input) ===== Capitalizes words in the input sentence. ===== camelize(input) and camelcase(input) ===== This filter returns a capitalized [[http://en.wikipedia.org/wiki/CamelCase|CamelCase]] form of the input string, after stripping it of spaces and funny characters just like handleize does. Both camelize(input) and camelcase(input) return the same values. Example: {{ variation.name }} ===== handleize(input) and handle(input) ===== This filter returns the handle form of the input string, in the same way that SandwichBoard generates handles out of the titles of products, pages, and collections. Non-word characters are stripped out and you end up with a nice lowercase dashed string, which is suitable for constructing URLs, HTML attribute values, or anything else that shouldn't have spaces or strange characters. Both handleize(input) and handle(input) return the same values. Example: {{ variation.name }} ===== pluralize(size, singular_word) ===== This filter determines whether or not to pluralize a word based on the size of a number. It returns the size plus the singular or plural form of the word. Example: {{ album.images | size | pluralize: 'Image' }} 0 Images 1 Image 2 Images ===== truncate(input, length = 50, truncate_string = "...") ===== Truncates a string down to x characters. Take care with truncating text which has html elements in it. In these cases you probably want to run the string through the strip_html filter first (see below). ===== truncatewords(input, words = 15, truncate_string = "...") ===== Truncates a string down to x words. ===== simple_format(input) ===== Returns text transformed into HTML using simple formatting rules. Two or more consecutive newlines(''\n\n'') are considered as a paragraph and wrapped in ''

'' tags. One newline (''\n'') is considered as a linebreak and a ''
'' tag is appended. This method does not remove the newlines from the text. ===== strip_html(input) ===== This will strip all html tags from the text passed to the block. Very useful in combination with truncate. ====== Collection Liquid Filters ====== ===== join(array, glue = ' ') ===== Joins elements of an array with certain character between them. The default character is a space. ===== sort(array) ===== Sorts the elements of an array. ===== size(array_or_string) ===== Returns the size of an array or of an string. ===== first(array) ===== Gets the first element of the passed in array. Example: {{ menu.sections | first }} ===== last(array) ===== Gets the last element of the passed in array. Example: {{ menu.sections | last }} ====== Date and Currency Liquid Filters ====== ===== date(input, format) ===== Reformat a date: %a - The abbreviated weekday name (``Sun'') %A - The full weekday name (``Sunday'') %b - The abbreviated month name (``Jan'') %B - The full month name (``January'') %c - The preferred local date and time representation %d - Day of the month (01..31) %e - Day of the month, without a leading zero (1..31) %H - Hour of the day, 24-hour clock (00..23) %I - Hour of the day, 12-hour clock (01..12) %j - Day of the year (001..366) %l - Hour of the day, 12-hour clock (1..12) %m - Month of the year (01..12) %M - Minute of the hour (00..59) %p - Meridian indicator (``AM'' or ``PM'') %S - Second of the minute (00..60) %U - Week number of the current year, starting with the first Sunday as the first day of the first week (00..53) %W - Week number of the current year, starting with the first Monday as the first day of the first week (00..53) %w - Day of the week (Sunday is 0, 0..6) %x - Preferred representation for the date alone, no time %X - Preferred representation for the time alone, no date %y - Year without a century (00..99) %Y - Year with century %Z - Time zone name %% - Literal ``%'' character {{ event.date | date: '%B %e, %Y' }} {{ event.time | date: '%l:%M %p' }} ===== number_to_currency(number) ===== Formats a number into a currency string. Period and cents will only be returned if not zero. ===== number_to_currency_with_cents(number, options = {}) ===== Formats a number into a currency string. Period and cents will always be returned. ====== Other Liquid Filters ====== ===== assign_to(value, name) ===== Assigns a value to a named Liquid variable for use later in the current template or page. {{ 5 | assign_to: 'my_integer' }} ===== assign_to_global(value, name) ===== Assigns a value to a named Liquid variable for use later in the current and any enclosing template or page.