Firebird can produce highly customisable emails and documents using the data collected within your project.


Firebird uses Handlebars for precise control over which data is displayed and how it is formatted.


Handlebars allows simple merge fields to be displayed, allows fields to be pulled out of nested data structures and to provide conditional logic to control what data is displayed.


This article outlines the different handlebars codes that can be used along with some examples.


Merge fields

To display data pulled out of your project, insert a merge field expression using the following format:


{{ObjectName.FieldName}}


Merge Field
Description

{{Submitter.FirstName}}

The first name of the submitter of the submissions
{{Project.SubmissionDeadline}}
The date stored in the Submission Deadline field in the Project Settings
{{Submission.ReferenceNumber}}
The unique reference number of a submission


Each

If your data contains more than one item of the same type e.g. Multiple submissions for a single submitter, then you can look through the records by using a loop using the each keyword:


{{#each ObjectNames}} ....  {{/each}}


There are two parts to the each expression, the {{#each}} and the {{/each}}. Between these two parts, the context is changed to the object that is being looped through.


Each
Description

{{#each Submitter.Submissions}}

   {{ReferenceNumber}} {{Title}}

{{/each}}

Loop through each of the submitter's submissions and display the reference number and title.  Inside the each loop, the context is that of a Submission and so the ObjectName is not required in the merge field
{{#each Reviewer.Reviews}}
{{Submission.ReferenceNumber}}
{{/each}}
Loop through each of the reviewer's reviews and display the reference number of the associated submission


If

Sometimes, data should only be shown under certain conditions.  The if expression allows the template to check is something is available before displaying contents


{{#if ObjectName.FieldName}} .... {{/if}}


There are two parts to the if expression, the {{#if}} and the {{/if}}.  The content between these two parts is only displayed if the if item is available or set to true


If
Description

{{#if Submitter.HasSingleSubmission}}

   You only have one submission

{{/if}}

Only display the "You only have one submission text" text if the submitter has a single submission
{{#if Reviewer.HasMultipleReviews}}
You have {{Reviewer.Reviews.Count}} reviews
{{/each}}
If the reviewer has more than one review then display the number of reviews



IfEqual


Sometimes the value of a field needs to be the same as a specific value or another field's value


{{#ifEqual ObjectName.FieldName Value}} .... {{/ifEqual}}


{{#ifEqual ObjectName.FieldName OtherObject.OtherField}} .... {{/ifEqual}}



There are two parts to the ifEqual expression, the {{#ifEqual}} and the {{/ifEqual}}.  The content between these two parts is only displayed if the ifEqual expression is true.


IfEqual
Description

{{#ifEqual Submitter.FirsInitial 'A'}}

  You will be first

{{/ifEqual}}

Only display the "You will be first" text if the submitter's first initial is equal to 'A'
{{#ifEqual ReviewType.Name 'PaperReview'}}
This is a Paper Review
{{/ifEqual}}
Only display the "This is a Paper Review" text if the review type has the name of 'PaperReview'


IfNotEqual

Sometimes the value of a field needs to be different to a specific value or another field's value


{{#ifNotEqual ObjectName.FieldName Value}} .... {{/ifNotEqual}}


{{#ifNotEqual ObjectName.FieldName OtherObject.OtherField}} .... {{/ifNotEqual}}



There are two parts to the ifNotEqual expression, the {{#ifNotEqual}} and the {{/ifNotEqual}}.  The content between these two parts is only displayed if the ifNotEqual expression is false.


IfNotEqual
Description

{{#ifNotEqual Submitter.FirsInitial 'A'}}

  You will not be first

{{/ifNotEqual}}

Only display the "You will be first" text if the submitter's first initial is equal to 'A'
{{#ifNotEqual ReviewType.Name 'PaperReview'}}
This is not a Paper Review
{{/ifNotEqual}}
Only display the "This is a Paper Review" text if the review type has the name of 'PaperReview'


Format

Sometimes field data needs to be formatted in a particular way.


{{format ObjectName.FieldName formatString}}


The format expression takes two parameters.  The first is the merge field for the data to be displayed.  The second is a string describing how to format that data.


Format
Description

{{format ReferenceNumber '0000'}}


Display the reference number with exactly 4 digits
{{format Project.EndDate 'dd MMMM yyyy'}}
Format the end date for the project using 2 digits for the date, the long month name and four digits for the year e.g. 12 January 2016


Standard format strings are defined on the Microsoft website.


Dates and Times

Standard Date and Time Format Strings

Custom Date an Time Format Strings


Numbers

Standard Numeric Format Strings

Custom Numeric Format Strings


Contains

Sometimes content needs to be displayed if a collection of objects contains a certain value


{{#contains ObjectNames FieldName Value}} .... {{/contains}}


There are two parts to the contains expression, the {{#contains}} and the {{/contains}}. The content between these two parts is only displayed if the contains expression is true.


ContainsDescription

{{#contains Customer.OrderItems "ProductId" 29}}

   SPECIAL PRODUCT

{{/contains}}

Only display the "SPECIAL PRODUCT" text if the customer's order items contains the product with id of 29
{{#contains Submission.Authors "Presenter" "True"}}
PRESENTER
{{/contains}}
Only display the "PRESENTER" text if the submission has an author that is flagged as "Presenter"



BoldBracketHtml

Sometimes part of a text has to be highlighted based on a condition.


{{#boldBracketHtml}} .... {{/boldBracketHtml}}

{{#boldBracketHtml condition}} .... {{/boldBracketHtml}}


There are two parts to the boldBracketHtml expression, the {{#boldBracketHtml}} and the {{/boldBracketHtml}}. The content between these two parts is always displayed. If the condition is missing or it is True, the content will put in the <b></b> html tags and square brackets.


BoldBracketHtmlDescription

{{#boldBracketHtml}}

  This will be bracketed and bold

{{/boldBracketHtml}}

It will output the following html: "<b>[This will be bracketed and bold]</b>"

{{#boldBracketHtml condition}}

  This might be bracketed and bold

{{/boldBracketHtml}}

It will output the following html if condition is True: "<b>[This might be bracketed and bold]</b>"
Or if condition is False: "This might be bracketed and bold"

{{#boldBracketHtml (equal Object.Property OtherValue)}}

  This will be bracketed only if Object.Property equals OtherValue

{{/boldBracketHtml}}

Checks if Object.Property equals to OtherValue, and displays the content highlighted or not highlighted accordingly



Icon

Add an Icon to your webpage.  


{{Icon 'IconName'}}


NOTE: Html Only. This helper will not work for content generated for Word or PDF output.


Icon
Description

{{Icon 'Location'}}

Displays a Location icon


StrikeHtml

Sometimes part of a text has to be striked based on a condition.


{{#strikeHtml}} .... {{/strikeHtml}}

{{#strikeHtml condition}} .... {{/strikeHtml}}


There are two parts to the strikeHtml expression, the {{#strikeHtml}} and the {{/strikeHtml}}. The content between these two parts is always displayed. If the condition is missing or it is True, the content will put in the <strike></strike> html tags.


StrikeHtmlDescription

{{#strikeHtml}}

  This will be striked

{{/strikeHtml}}

It will output the following html: "<strike>This will be striked</strike>"

{{#strikeHtml condition}}

  This might be striked

{{/strikeHtml}}

It will output the following html if condition is True: "<strike>This might be striked</strike>"
Or if condition is False: "This might be striked"

{{#strikeHtml (equal Object.Property OtherValue)}}

  This will be striked only if Object.Property equals OtherValue

{{/strikeHtml}}

Checks if Object.Property equals to OtherValue, and displays the content striked or not striked accordingly



GetValueOrDefault

Sometimes the underlying data structure is a lookup dictionary and we need a value for a given key


{{getValueOrDefault dictionary key}}

{{getValueOrDefault dictionary key default}}



GetValueOrDefaultDescription

{{getValueOrDefault dictionary key}}

It will output the value from the dictionary for the given key. If the key is not found it will not output anything.

{{getValueOrDefault dictionary key default}}

It will output the value from the dictionary for the given key. If the key is not found it will output the default parameter.



List

Sometimes a list needs to be displayed with the items separated


{{#list values separator}} .... {{/list}}


There are two parts to the list expression, the {{#list}} and the {{/list}}. Between these two parts, the context is changed to the object that is being looped through. Between each iteration, the separator will be placed, but not in front of the first or after the last item.


ListDescription

{{#list Reviewer.Reviews ', '}}
{{Submission.ReferenceNumber}}
{{/list}}

Loop through each of the reviewer's reviews and display the reference number of the associated submission separated by commas.



Equal


Sometimes the value of a field needs to be the same as a specific value or another field's value


{{Equal ObjectName.FieldName Value}}


{{Equal ObjectName.FieldName OtherObject.OtherField}}



This can be used as a parameter for other helpers which require a True/False value, see BoldBracketHtml for an example.


Equal
Description

{{Equal Submitter.FirsInitial 'A'}}

Displays "True" if the submitter's first initial is equal to 'A' or "False" if it isn't


PlainText

Sometimes you need to display the value of a field or complete block as plain text. 


{{plainText ObjectName.FieldName}}

{{#plainText}} .... {{/plainText}}


The plainText expression can be used in two ways, either for fields or for complete blocks as the example shown above. Please note, that when in templates for HTML documents this template should not be used.


StrikeHtmlDescription

{{#plainText}}

  <p> Html &hArr; plain </p>

{{/plainText}}

It will output the following: "Html ⇔ plain"

{{#plainText ObjectName.FieldName}}

It will output the value of ObjectName.FieldName as plaintext, without the HTML formatting.