Last active
January 4, 2017 09:42
-
-
Save shackep/d5608614779df0f08eadec46605418e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# To make these available in your template, you will need to: {% import "/component_helpers.html" as helpers %} #} | |
{# Convert a date to a specific format: 19th April 2016 #} | |
{% macro date_formatted(givenDate) %} | |
{{ givenDate | date('jS F Y') }} | |
{% endmacro %} | |
{# Usage: {{ helpers.givenDate(post.date)}} #} | |
{# Use an svg associated background image #} | |
{% macro watermark(svg) %} | |
<div class="icon-sr_{{ svg|lower|replace(' ', '-') }}_watermark"></div> | |
{% endmacro %} | |
{# Usage: {{ helpers.watermark(post.pub_type) }} #} | |
{# Changes shorthand office names into Office city names #} | |
{% macro office_name(ugly_office_name) %} | |
{% set values = [''] %} | |
{% if 'MI301' in ugly_office_name %} | |
{% set values = values|merge(['Ann Arbor']) %} | |
{# Ann Arbor #} | |
{% endif %} | |
{% if 'NY2Rector' in ugly_office_name %} | |
{% set values = values|merge(['New York']) %} | |
{# New York #} | |
{% endif %} | |
{% if 'NJ100' in ugly_office_name %} | |
{% set values = values|merge(['Princeton']) %} | |
{# Princeton #} | |
{% endif %} | |
{% for value in values %} | |
{{ value }}{% if loop.index > 1 and not loop.last %} & {% endif %} | |
{% endfor %} | |
{% endmacro %} | |
{# Usage: {{ helpers.office_name(user.office) }} #} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment