Advice and answers from the Device Magic Team

We have been working on improving our word/pdf template system to work for really big forms / templates and to incorporate new options to improve the templates we are able to render.

The new template system will work as expected for all existing templates, the difference is that we can now add extra options to the placeholders.

Fields are placed normally as before using:

##{{ fields.Free_Text_Question }}

Sub-forms are also accessed as before using:

##{{ fields.Subform.Free_Text_question }}

Repeat groups are also displayed as before by referencing the Repeat Group:

##{{ fields.Group }}, ##{{ fields.Group | full_width }}, ##{{ fields.Group | list }}

Available Options:

Note: For more than one option, separate options with commas, e.g. ##{{ fields.Group | list, filter_fields: [Free_Text_Question, Image_Question] }}

Text Questions:

Capitalize:

Will capitalize the answer. e.g. "yes" will become "Yes"

##{{ fields.Text_Question | capitalize }}

##{{ fields.Yes_No_Question | capitalize }}

Decimal / Integer Questions:

Currency:

##{{ fields.DecimalQuestion | currency }} - Will leave 2 spaces after the decimal e.g. 24.2326 will become 24.23

Image Questions:

Image Size:

##{{ fields.SketchQuestion | 100x100 }} - Will resize the image to 100x100 (any numbers can be used here)

Multi-select questions:

each_answer_on_new_line:

##{{ fields.SelectQuestion | each_answer_on_new_line }} - Will place each answer from the multi-select on a new line instead of on one line separated by commas.

separator:

If you would like to separate the answers with something other than the default "," you can specify it using the separator method.

##{{ fields.SelectQuestion | separator: "; " }} - Will result in the options being separated by ; - e.g. Answer1; Answer2; Answer3

Location questions:

size:

Location questions can now be resized in the same way as image questions.

##{{ fields.LocationQuestion | 100x100 }} - Will resize the map to 100x100 (any numbers can be used here)

hyperlink:

The map image displayed can be set to link to google maps. Simply set hyperlink: true.

##{{ fields.LocationQuestion | hyperlink: true }}

show_coordinate_info:

By default coordinate information is shown below the map image for a location question. You can now disable this with show_coordinate_info: false

##{{ fields.LocationQuestion | show_coordinate_info: false }}

--

Location questions can now be formatted to display however you like by using a template with the shot_coordinate_info option.

You simply provide a layout for the parts of the date using the placeholders from this article:

https://devicemagic.zendesk.com/word-templating/word-templating/word-template-location-formatting-options

e.g.

##{{ fields.Date | show_coordinate_info: "%lat, %long"}} which will display the location as -31.1353253, 18.1353252.

Note: You cannot use [] or {} in the layout. If you want to use commas , you need to surround the layout in quotation marks - e.g. "%lat, %long"

hide_map:

By default a map image is shown. You can now disable this with hide_map: true

##{{ fields.LocationQuestion | hide_map: true }}

Date / Time questions:

date_time_format:

Date and/or Time questions can now be formatted to display however you like by using the date_time_format option.

You simply provide a layout for the parts of the date using the placeholders from this article:

https://devicemagic.zendesk.com/word-templating/word-templating/word-template-date-time-formatting-options

e.g.

##{{ fields.Date | date_time_format: %d %B %Y }} which will display the date as 01 June 2015.

Note: You cannot use [] or {} in the layout. If you want to use commas , you need to surround the layout in quotation marks - e.g. "%d %B, %Y"

Repeat Group questions:

Note: To output repeat groups with a custom layout, please see For Loops in this article: Word-Format-New-Advanced-Templating-Options

style:

Repeat Groups can either be displayed in a table or a list format.

Table puts the answers into a table with the labels as the headers.

List puts the answer one under the other with the labels.

##{{ fields.Group }} - For the Table format

##{{ fields.Group | full_width }} - for the maximum width Table format

##{{ fields.Group | list }} - for the List format

filter_fields:

Users are now able to filter which fields are displayed, this works with the default table mode and the list option.

The basic syntax is

filter_fields: [field, field]

Sub-groups in groups can be filtered as well by giving a sub section when specifying the fields: e.g.

filter_fields: [field1, field2: [subfield1, subfield2], field3]

##{{ fields.Group | list, filter_fields: [Question1, Question2: [SubQuestion2_1, SubQuestion2_2], Question3] }}

image_size:

Images in repeat groups can be resized now using image_size.

The syntax is

image_size: [width]x[height]

e.g.

image_size: 100x100

##{{ fields.Group | list, image_size: 300x100 }} (for a list format)

##{{ fields.Group | image_size: 300x100 }} (for the default table format)

map_size:

Maps in repeat groups can be resized now using map_size.

The syntax is

map_size: [width]x[height]

e.g.

map_size: 100x100

##{{ fields.Group | list, map_size: 300x100 }}

show_labels:

Use this to hide the headers / labels that are displayed by default.

The syntax is

show_lables: false

e.g.

##{{ fields.Group | show_labels: false }}

**Chaining Options

Note: You can use multiple options on repeat groups and other fields.

Just separate the options with , characters.

e.g.

##{{ fields.Group | map_size: [100x100], filter_fields: [a,b], show_labels: false }}

##{{ fields.Group | list, filter_fields: [a,b], map_size: [100x100], show_labels: false }}

##{{ fields.Group | full_width, show_labels: false, map_size: [100x100], filter_fields: [a,b] }}

Advanced Options

It is now possible to build out repeat groups manually and to optionally show content. Please view the advanced templating article here:

Word-Format-New-Advanced-Templating-Options

Please let us know of any extra options you would like in the templating system.

Did this answer your question?