SheepCRM templates are used for automatic emails and can be used by your team for bulk or one-off emails. The templates use Markdown but html can also be included. We recommend using the test send feature to check the formatting before sending.

Common Markdown

# Main Header (one hash mark)

## Sub Header (two hash marks)

Emphasis, aka italics, with *asterisks* or _underscores_.

Strong emphasis, aka bold, with **asterisks** or __underscores__.

Combined emphasis with **asterisks and _underscores_**.

Main Header (one hash mark)

Sub Header (two hash marks)

Emphasis, aka italics, with asterisks or underscores.

Strong emphasis, aka bold, with asterisks or underscores.

Combined emphasis with asterisks and underscores.

You can include links to websites by surrounding the text you want to link in square brackets [ ] and follow with the URL you want in rounded brackets ( ). e.g.

Click [here to go to Google Website](https://www.google.com)

becomes

Click here to go to Google Website

Template Tags

You can personalise the emails using template tags. These allow you to insert data from the database into the email. The most common use is to insert the recipients first name into the salutation e.g.

Hi {{first_name}},

becomes

Hi James,

Information about the recipient is always available for use in the template. Additional data will depend on the context e.g. a ticket purchase or a membership.

Common Fields

  • {{first_name}} (person only)

  • {{last_name}} (person only)

  • {{address_lines}} (a list on one line)

  • {{address_lines|formatlistwithnewlines}} (one per line)

  • {{locality}}

  • {{region}}

  • {{postal_code}}

  • {{primary_email}} (single)

  • {{email}} (a list of emails)

  • {{telephone}} (a list of phone numbers)

  • {{formatted_name}}

Tickets

  • {{ticket.buyer}}

  • {{ticket.ticket_id}}

  • {{ticket.ticket_type}}

  • {{ticket.date}}

  • {{ticket.reference}}

  • {{ticket.amount}}

Membership

  • {{member.membership_number}} 

  • {{member.plan_name}} 

  • {{member.plan_public_name}}  

  • {{member.period_date_range}}  eg. 12 months (2019-05-22 - 2020-05-22)

  • {{member.start_date}} 

  • {{member.end_date}} 

  • {{member.amount}}

  • {{member.membership_record_status}}  

  • {{member.auto_renew}} 

  • {{member.admin_contact}} 

  • {{member.linked_members}} (list)

  • {{member.plan_cost}} - the base cost excluding any discounts when the member renews

  • {{member.plan_currency}}   - the currency of the membership plan

  • {{member.plan_description}} 

Booking

  • {{booking.title}}

  • {{booking.date_range}}

  • {{booking.start_date}}

  • {{booking.start_datetime}}

  • {{booking.end_date}}

  • {{booking.end_datetime}}

  • {{booking.venue_for_display}}

  • {{booking.activity_for_display}}

Booking fields are also available when a ticket is selected

Donation

  • {{donation.amount}}

  • {{donation.appeal.display_value}} / This is the name of the Appeal

  • {{donation.currency}}

  • {{donation.date}}

Group Membership

  • {{group_member.group_name}}

  • {{group_member.status}}

  • {{group_member.role}}

  • {{group_member.group_category}}

Link tags generate a URL in the email from a short 'tag'.

Invoices

A PDF invoice link (an invoice URI or a membership URI can be used)

{{invoice.uri|invoice_pdf(‘download your invoice’)}}

or

{{member.uri|invoice_pdf(‘download your invoice’)}}

Link to the invoice within the Sheep App

{{member.uri|invoice(‘view your invoice’)}}

Receipts

{{payment.uri|receipt_pdf(‘download your receipt’)}}


Membership Certificates

{{member.uri|certificate_pdf(‘download your certificate’)}}

 or with custom template

{{member.uri|certificate_pdf('link text goes here','template-certificate-a5')}} 

Formatting Controls

Use formatting controls to change the normal output. Date formats are the most common control.

Date Time Format

houselongtime

{{booking.start_datetime|datetimeformat('house_long_time')}}

e.g. Monday, 03 July 2017 16:00

house_long

{{booking.start_datetime|datetimeformat('house_long')}}

e.g. Monday, 03 July 2017

custom

{{booking.start_datetime|datetimeformat('{:%Y-%m-%d}')}}

e.g. 2017-07-03

{{member.end_date|datetimeformat('{:%-d %b %Y}')}} 

3 Jul 2017

The custom formats use the python date format definitions

Adding and subtracting dates.

This isn't really supported but with a bit of work it can be achieved e.g.

The day today is: {{now|datetimeformat('house_long')}} but a week ago it was {{(now|datetimeformat('{:%s}')|integer-(7*60*60*24))|datetimeformat('house_long')}} 

(Convert the date back to seconds, convert from a string to an integer, do the subtraction, convert back to a date string)

List on multiple lines

{{address_lines|formatlistwithnewlines}}

e.g.
Flat 1a
The Cresent
Peak Road

List with commas

{{address_lines|formatlistwithcommas}}

e.g. Flat 1a, The Cresent, Peak Road

Numbers

{{amount|integer}}  12.345 becomes 12
{{amount|decimal}}  12.345 becomes 12.35

Creating Conditional Statements

Email templates can also handle conditional statements, these can be helpful when the template needs to handle different membership plans, or missing information. These can let you show different content based on whether the conditional statement is met for the particular recipient.

Basic 'if' conditional

To check if the tag exists, you can use {% if tag %}, follow with the content and/or tag, then close the conditional with {% endif %}. The example below will check if the recipient's first_name exists, if so it will display it:

Hello {% if first_name %}{{first_name}}{% endif %}

Output (with first_name):

Hello John

Output (without first_name)

Hello

This can also be done in shorter and more concise code. The above conditional has been condensed into the 'shorthand' conditional below - both methods are viable and both will return the same outcome:

Hello {{ first_name or '' }}

Please note: if you are planning on send out email to organisations, using person only tags will results in errors. If you planning on using person only tags on bulk emails, please add a conditional to check if the tag is defined:

{% if first_name is defined %}{{first_name}}{% endif %}

Advanced 'if/else' conditional

Conditionals can also be created to display a fallback if the condition is not met. This is done by adding a {% else %} block with content to handle if the condition is not met.

{% if first_name %}
Dear {{first_name}},
{% else %}
Dear member,
{% endif %}

Output (with first_name):

Dear John,

Output (without first_name):

Dear member,

This can also be done in shorter and more concise code. The above conditional has been condensed into the 'shorthand' conditional below - both methods are viable and both will return the same outcome:

Dear {{ first_name or 'member' }},

Example Conditional Statements

{% if first_name == 'john' %}{% endif %}

Checks if the first_name tag equals 'john'

{% if first_name != 'john' %}{% endif %}

Checks if the first_name tag does not equal 'john'

{% if first_name in ['john', 'mary', 'james'] %}{% endif %}

Checks if the first_name tag matches 'john', 'mary', or 'james'

Advanced

To see all available fields use the following:

__fields__

The output is a list of all fields.

To see all data (fields and values)

__all__

This will show a barely readable view of the data packet.

The __all__ syntax is useful for handling fields with hyphens or other characters not permitted by the template

__all__["externalid_my-field-with-hyphens"] 

Did this answer your question?