Helpers provides a way of manipulating data through functions. In this section you can find description of custom flex template language helpers. You can also use any of Handlebars built-in helpers.
Formats a string to uppercase.
{{format_uppercase expression}}
Usage:
{{format_uppercase 'super TEST string'}}
returns
SUPER TEST STRING
Formats a string to lowercase.
{{format_lowercase expression}}
Usage:
{{format_lowercase 'super TEST string'}}
returns
super test string
Formats a string to CamelCase.
{{format_camelcase expression}}
Usage:
{{format_camelcase 'super TEST string'}}
returns
Super Test String
Returns currency short format.
{{format_currencysymbol expression}}
Usage:
{{format_currencysymbol 'ZAR'}}
{{format_currencysymbol 'USD'}}
{{format_currencysymbol 'GBP'}}
{{format_currencysymbol 'THB'}}
returns
R
$
ÂŁ
฿
Returns a user friendly styled size string. Remove decimal places and convert any m2 to m².
{{format_size expression}}
Usage:
{{format_size '239.000 m2'}}
returns
239m²
Returns a number to Yes or No.
{{format_yesno expression}}
Usage:
{{format_yesno 0}}
{{format_yesno 1}}
returns
No
Yes
Returns a number formated with thousand separator.
{{format_numbersep expression}}
Usage:
{{format_numbersep 4500000}}
returns
4,500,000
Returns a string limited by the number of characters in the limit variable.
{{format_stringsize expression limit}}
Usage:
{{format_stringsize 'This is a long sentence' 7}}
returns
This is...
Replaces 'find' text in a expression with 'replace' string.
{{format_replace expression find replace}}
Usage:
{{format_replace 'This is a sample.' 'sample' 'sentence'}}
returns
This is a sentence.
Replaces the telephone expression with a user friendly telephone string.
{{format_phone expression}}
Usage:
{{format_phone '0828881111'}}
returns
082 888 1111
Encode string to the appropriate url format
{{format_url expression}}
Usage:
{{format_url 'Taling Ngam'}}
returns
taling-ngam
Format regular text with special characters like line breaks into HTML
{{{format_as_html expression}}}
Usage:
{{{format_as_html 'General:\n•Plot size: 1106 m²\n•Residence size: 740 m²'}}}
returns
<p>General:</p>
<p>
<ul>
<li>Plot size: 1106 m²</li>
<li>Residence size: 740 m²</li>
</ul>
</p
Formats a string to google place format for embed map.
{{format_google_place expression}}
Usage:
{{format_google_place 'Shop 6 Ashley Corner\n94 Marianhill Road\nPinetown\n3610'}}
returns
Shop+6+Ashley+Corner,94+Marianhill+Road,Pinetown,3610
Compose url from object fields and string with placeholders
{{compose_url entry format}}
Usage:
{{compose_url listings.0 '{{propertyType}}-{{propertyStatus}}-in-{{suburb}}-{{propertyid}}'}}
returns
house-for-sale-in-taling-ngam-922798.html
or with website expression
{{compose_url listings.0 @root.website.url_format_property}}
returns
house-for-sale-in-taling-ngam-922798.html
Allow to set value to any variable for further use. Mostly used for filtering, sorting, limiting.
{{set name value}}
WARNING: never set a new value for predefined variables (see expressions) as they can be reused between pages for performance reasons.
Usage:
{{set 'myvar' 123}}
{{myvar}}
returns
123
Allow to filter any array. Should be used with set helper
{{filter array field_name field_value_1 field_value_2 field_value_3 ...}}
Usage:
{{set 'listings_for_sale' (filter listings 'propertyStatus' 'For Sale')}}
{{each listings_for_sale}} ... {{/each}}
returns
All listings with 'For Sale' status
or
{{set 'listings_for_sale' (filter listings 'propertyStatus' 'For Sale' 'Pending Sale')}}
{{each listings_for_sale}} ... {{/each}}
returns
All listings with 'For Sale' or 'Pending Sale' status
Allow to sort any array. Should be used with set helper
{{filter array field_name order}}
Order values: asc
, desc
Usage:
{{set 'listings_by_price_desc' (sort listings 'price' 'desc')}}
{{each listings_by_price_desc}} ... {{/each}}
returns
All listings sorted by price in descending order
Allow to limit any array. Should be used with set helper
{{limit array size}}
Usage:
{{set 'listings_top_3' (limit listings 3)}}
{{#each listings_top_3}} ... {{/each}}
Allow to group array by some fields
{{group_by array field1 field2 ...}}
Usage:
{{set 'suburbs_by_town' (group_by facets_suburb 'town')}}
{{stringify suburbs_by_town}}
[
{
"value": "CAPE TOWN",
"items": [
{
"count": 4,
"suburb": "DIEP RIVER",
"town": "CAPE TOWN",
"province": "WESTERN CAPE"
},
{
"count": 1,
"suburb": "SEA POINT",
"town": "CAPE TOWN",
"province": "WESTERN CAPE"
},
]
},
{
"value": "HERMANUS"
"items": [
{
"count": 1,
"suburb": "HERMANUS",
"town": "HERMANUS",
"province": "WESTERN CAPE"
}
]
}
]
Allow to calculate facets after limit and filter operations. Should be used with set helper
{{calculate_facets listings}}
Usage:
{{set 'listings_top_3' (limit listings 3)}}
{{set 'facets_top_3' (calculate_facets listings_top_3)}}
{{#each facets_top_3.facets_suburb}} ... {{/each}}
Returns a string representation of javascript object. Can be used for debug in development process.
{{stringify expression}}
Usage:
{{stringify listings.0}}
returns
{"agent_name":"John", "agent_lastname":"Dow", "agent_role":"Office Administrator", ...}
Allow to embed any object into the javascript code.
{{json expression}}
Usage:
<script>
var listings = {{json listings}};
</script>
Allow to embed react components into page
{{embed_component component_name [container_name] [data]}}
Helper use component_name
as container_name
if container_name
not presented. Also you can pass extra data that will be available on page under COMPONENT_DATA
global variable.
Usage:
<div id="search-bar"></div>
... end of the page ...
{{embed_component 'search-bar'}}
or
<div id="my-container"></div>
... end of the page ...
{{embed_component 'search-bar' 'my-container'}}
or
<div id="my-container"></div>
... end of the page ...
{{embed_component 'property-alerts' 'my-container' extraData}}
Allow to embed partial template into page
{{embed_partial partial_name}}
To get the idea of partial templates you can see special page.
Usage:
{{embed_partial 'header'}}
{{embed_partial 'footer'}}
Allow to check if field equal to value or other field
{{#if (eq value1 value2)}}
// true
{{else}}
// false
{{/if}}
Usage:
{{#if (eq listing.0.propertyStatus 'For Sale')}}
// Special markup for properties with 'for sale' status
{{else}}
// Regular markup
{{/if}}
Allow to check if field not equal to value or other field
{{#if (neq value1 value2)}}
// true
{{else}}
// false
{{/if}}
Usage:
{{#if (neq listing.0.propertyStatus 'For Sale')}}
// Markup that only need for properties with status different from 'for sale'
{{/if}}
Allow to check if field greater than value or other field
{{#if (gt value1 value2)}}
// true
{{else}}
// false
{{/if}}
Usage:
{{#if (gt listing.0.bedrooms 3)}}
// Markup that only need for properties with more than 3 bedrooms (4+)
{{/if}}
Allow to check if field greater than or equal to value or other field
{{#if (gte value1 value2)}}
// true
{{else}}
// false
{{/if}}
Usage:
{{#if (gte listing.0.bedrooms 3)}}
// Markup that only need for properties with more than 2 bedrooms (3+)
{{/if}}
Allow to check if field less than value or other field
{{#if (lt value1 value2)}}
// true
{{else}}
// false
{{/if}}
Usage:
{{#if (lt listing.0.price 1000000)}}
// Markup that only need for properties cheaper than 1 000 000
{{/if}}
Allow to check if field less than or equal to value or other field
{{#if (lte value1 value2)}}
// true
{{else}}
// false
{{/if}}
Usage:
{{#if (lte listing.0.price 1000000)}}
// Markup that only need for properties cheaper than or equal 1 000 000
{{/if}}
Allow to retrieve record from Airtable by specifying multiple key/value pair which will be used to filter all Airtable records. If more then one record found, you will receive first one. If no match found, you will receive empty object.
{{plugin_airtable_retrieve key1 value1 key2 value2 key3 value3 key4 value4 ...}}
Usage:
{{set 'airtable_record' (plugin_airtable_retrieve 'Town' 'Bloemfontein' 'Province' 'Free State')}}
{{airtable_record.[Summary Overview]}}
Allow to retrieve records from Airtable by specifying multiple key/value pair which will be used to filter all Airtable records. If no matches found, you will receive empty array.
{{plugin_airtable_retrieve_all key1 value1 key2 value2 key3 value3 key4 value4 ...}}
Usage:
{{set 'airtable_records' (plugin_airtable_retrieve_all 'Country' 'South Africa')}}
{{#each airtable_records}}
...
{{/each}}
Allow to retrieve office record related to agent.
{{get_agent_office agent offices}}
Usage:
{{set 'office' (get_agent_office agent offices)}}
{{stringify office}}
Allow to retrieve property records related to agent. Default limit - 10.
{{get_agent_properties agent listings limit}}
Usage:
{{set 'properties' (get_agent_properties agent listings)}}
{{#each properties}}
...
{{/each}}
Allow to retrieve agent records related to office. Default limit - 10.
{{get_office_agents office agents limit}}
Usage:
{{set 'office_agents_5' (get_office_agents office agents 5)}}
{{#each office_agents_5}}
...
{{/each}}
Allow to retrieve agent records related to property. Default limit - 10.
{{get_property_agents property agents limit}}
Usage:
{{set 'property_agents' (get_property_agents property agents)}}
{{#each property_agents}}
...
{{/each}}
Allow to create areas filter object:
{{compose_area town [suburb]}}
Usage:
{{set 'custom_area' (compose_area 'Cape Town')}}
// { areas: [{ town: 'Cape Town' }] }
{{set 'custom_area' (compose_area 'Cape Town' 'Diep River')}}
// { areas: [{ town: 'Cape Town', suburb: 'Diep River' }] }
Allow to create custom object:
{{compose_object field1 value1 field2 value2 ...}}
Usage:
{{set 'custom_object' (compose_object 'a' 42 'b' 'xyz')}}
{{custom_object.a}}
{{custom_object.b}}
Allow to create custom array:
{{compose_array value1 value2 ...}}
Usage:
{{set 'custom_array' (compose_object 'a' 'b')}}
{{#each custom_array}}
...
{{/each}}
Allow to receive URL of medium size version of the photo if available.
Usage:
{{#each listings}}
{{#each photos}}
<img src="{{medium_size}}">
{{/each}}
{{/each}}
or
{{medium_size listings.0.photos.0}}
Allow to receive URL of small size version of the photo if available.
Usage:
{{#each listings}}
{{#each photos}}
<img src="{{small_size}}">
{{/each}}
{{/each}}
or
{{small_size listings.0.photos.0}}