Misc Filters
Provides miscellaneous filters.
date
Converts a timestamp into another date format.
Input
{{ listing.created_at | date: "%a, %b %d, %y" }}
Output
Tue, Apr 22, 14
The date parameters are listed below:
%a |
Abbreviated weekday.
|
%A |
Full weekday name.
|
%b |
Abbreviated month name.
|
%B |
Full month name
|
%c |
Preferred local date and time representation
|
%d |
Day of the month, zero-padded (01, 02, 03, etc.).
|
%-d |
Day of the month, not zero-padded (1,2,3, etc.).
|
%D |
Formats the date (dd/mm/yy).
|
%e |
Day of the month, blank-padded ( 1, 2, 3, etc.).
|
%F |
Returns the date in ISO 8601 format (yyyy-mm-dd).
|
%H |
Hour of the day, 24-hour clock (00 - 23).
|
%I |
Hour of the day, 12-hour clock (1 - 12).
|
%j |
Day of the year (001 - 366).
|
%k |
Hour of the day, 24-hour clock (1 - 24).
|
%m |
Month of the year (01 - 12).
|
%M |
Minute of the hour (00 - 59).
|
%p |
Meridian indicator (AM/PM).
|
%r |
12-hour time (%I:%M:%S %p)
|
%R |
24-hour time (%H:%M)
|
%T |
24-hour time (%H:%M:%S)
|
%U |
The number of the week in the current year, starting with the first Sunday as the first day of the first week.
|
%W |
The number of the week in the current year, starting with the first Monday as the first day of the first week.
|
%w |
Day of the week (0 - 6, with Sunday being 0).
|
%x |
Preferred representation for the date alone, no time. (mm/dd/yy).
|
%X |
24-hour time (%H:%M:%S)
|
%y |
Year without a century (00.99).
|
%Y |
Year with a century.
|
%Z |
Time zone name.
|
random
generate random numbers.
{{ 5 | random }}
# => 4 (the result is randomly print)
toggle_class_name
Return class_name if condition evaluate to true otherwise nil is returned.
{{ 'active' | toggle_class_name: true }}
# => 'active'
default
Sets a default value for any variable with no assigned value. Can be used with strings, arrays, and hashes.
Input
Dear {{ person.name | default: "person" }}
Input
<!-- if person.name is nil -->
Dear person
default_pagination
Creates a set of links for paginated results. Used in conjunction with the paginate variable.
Input
{{ paginate | default_pagination }}
Input
<span class="page current">1</span>
<span class="page"><a href="/galleries?page=2" title="">2</a></span>
<span class="page"><a href="/galleries?page=3" title="">3</a></span>
<span class="deco">…</span>
<span class="page"><a href="/galleries?page=17" title="">17</a></span>
<span class="next"><a href="/galleries?page=2" title="">Next »</a></span>
google_static_map_url
Generate google static map url for a listing
object with the provided options such as: maptype
, size
, …. Find out more HERE.
Input
{{ listing | google_static_map_url: size: '300x200' }}
Output
https://maps.googleapis.com/maps/api/staticmap?center=40.714728%2C-73.998672&maptype=roadmap&size=300x200&zoom=13&markers=color%3Ared%7C40.714728%2C-73.998672
open_closed
Format the display of the opening and closed hour of the business_hour
object.
Input
{{ business_hour | open_closed: '%I:%M %p-%I:%M %p' }}
Output
08:00 AM-12:00 PM