TABLE OF CONTENTS
Introduction to Handlebars (templating language)
Powered by Handlebars JS, the self-service portal provides a range of built-in helpers to assist with customization. In addition to standard Handlebars helpers, the portal includes custom helpers such as pagination, avatar, and renderfromapi to support your specific needs.
Partials
Partials serve as modular, reusable components that can be incorporated across various page templates. Common examples include:
“loaders”: A partial implemented across templates to show loading indicators while API data is fetched.
“ticket_new_form”: A partial utilized for displaying input fields within the new ticket creation interface.
You can utilize the provided default partials or build your own custom ones.
Note: These function as substitutes for "snippets" used in Liquid templates.
Placeholders / Params
The self-service portal features two categories of placeholders:
Global context placeholders: These can be utilized across any page template within the portal.
Dynamic / Local context placeholders: These are scoped to specific pages and typically correspond to the server API response parameters for that particular page.
Helpers
Default Helpers
length
Returns the length of the given string or array.
Params
value {Array|Object|String}
returns {Number}: The length of the value.
default
Returns the first value that is not undefined, otherwise the "default" value is returned.
Params
value {any}
defaultValue {any}
returns {String}
eq
Block helper that renders a block if a is equal to b. If an inverse block is specified it will be rendered when falsy. You may optionally use the compare="" hash argument for the second value.
Params
a {String}
b {String}
options {Object}: Handlebars provided options object
returns {String}: Block, or inverse block if specified and falsey.
gt
Block helper that renders a block if a is greater than b.
If an inverse block is specified it will be rendered when falsy. You may optionally use the compare="" hash argument for the second value.
Params
a {String}
b {String}
options {Object}: Handlebars provided options object
returns {String}: Block, or inverse block if specified and falsey.
lt
Block helper that renders a block if a is less than b.
If an inverse block is specified it will be rendered when falsy. You may optionally use the compare="" hash argument for the second value.
Params
context {Object}
options {Object}: Handlebars provided options object
returns {String}: Block, or inverse block if specified and falsey.
lte
Block helper that renders a block if a is less than or equal to b.
If an inverse block is specified it will be rendered when falsy. You may optionally use the compare="" hash argument for the second value.
Params
a {String}
b {String}
options {Object}: Handlebars provided options object
returns {String}: Block, or inverse block if specified and falsey.
gte
Block helper that renders a block if a is greater than or equal to b.
If an inverse block is specified it will be rendered when falsy. You may optionally use the compare="" hash argument for the second value.
Params
a {String}
b {String}
options {Object}: Handlebars provided options object
returns {String}: Block, or inverse block if specified and falsey.
ternary
Returns either of the two values provided based on the condition given.
Params
Condition {Boolean}
trueValue {String | Number}
falseValue {String | Number}
returns {String | Number}
isnt
Block helper that renders a block if a is not equal to b. If an inverse block is specified it will be rendered when falsy.
Params
a {String}
b {String}
options {Object}: Handlebars provided options object
returns {String}
not
Returns true if val is falsey. Works as a block or inline helper.
Params
val {String}
options {Object}: Handlebars provided options object
returns {String}
or
Block helper that renders a block if any of the given values is truthy. If an inverse block is specified it will be rendered when falsy.
Params
arguments {...any}: Variable number of arguments
options {Object}: Handlebars options object
returns {String}: Block, or inverse block if specified and falsey.
and
Helper that renders the block if both of the given values are truthy. If an inverse block is specified it will be rendered when falsy. Works as a block helper, inline helper or subexpression.
Params
a {any}
b {any}
options {Object}: Handlebars provided options object
returns {String}
startsWith
Block helper which tests whether a string begins with the given prefix and renders as if and else.
Params
prefix {String}
testString {String}
options {String}
returns {String}
ellipsis
Truncates a string to the specified length, and appends it with an ellipsis (…).
Params
str {String}
length {Number}: The desired length of the returned string.
returns {String}: The truncated string.
replace
Replace all occurrences of substring a with substring b.
Params
str {String}
a {String}
b {String}
returns {String}
lowercase
Lowercase all of the characters in the given string.
Params
str {String}
returns {String}
uppercase
Uppercase all of the characters in the given string. If used as a block helper it will uppercase the entire block. This helper does not support inverse blocks.
Params
str {String}: The string to uppercase
options {Object}: Handlebars options object
returns {String}
titleize
Title case the given string. From “this is sample text” to “This Is Sample Text”.
Params
str {String}
returns {String}
isEmpty
Inline, subexpression, or block helper that returns true (or the block) if the given collection is empty, or false (or the inverse block, if supplied) if the collection is not empty.
Params
collection {Object}
options {Object}
returns {String}
isObject
Return true if value is an object.
Params
value {String}
returns {Boolean}
isNumber
Return true if value is an object.
Params
value {String | Number}
returns {Boolean}
Custom Helpers
renderFromApi
A block helper that performs an API request. Upon completion—regardless of success or failure—it runs the specified block of code. Parameter configurations align with standard jQuery ajax options (excluding function parameters); please refer to the jQuery ajax documentation for details.
Params
url {String | Number}
Method {String}
Example:
{{#renderFromApi url="/support/v2/solutions/articles/popular" method="GET"}}
<section id="solutions-banner">
<h2>Trending Topics</h2>
{{#this}}
<a href="{{#if external_url}}{{external_url}}{{else}}/support/solutions/articles/{{id}}{{/if}}" class="card solution-card">
<div class="elem-inline-mid">
<h3>{{title}}</h3>
<p>{{description}}</p>
</div>
</a>
{{/this}}
</section>
{{/renderFromApi}}
avatar
Takes standard image tag parameters along with an additional parameter: name. It checks the specified URL for the user's profile image. If no profile picture is found, it renders the initial of the provided name over a randomly selected default image.
Example:
{{avatar name=user_info.full_name url=user_info.profile_pic class="user-profile-pic"}}
Pagination
The pagination helper functions as a block helper. It accepts the following parameters:
list: The collection of items to paginate.
id: Unique identifier for the pagination block.
paginationContainer: The navigation container ID where pagination links will be rendered.
class (optional): Additional CSS classes for styling.
perPage (optional): Specifies the number of items displayed per page.
page (optional): Sets the current page number.
params (optional): Additional request parameters.
Custom Events
To facilitate advanced customizations, the Self Service portal dispatches various events that can be monitored at either the document or container level.
Document Events
Events that can be monitored at the document level.
Example:
$(document).on('PageChange', function(e) {
new FSToastr({
message: 'New Page Alert',
type: 'success'
}, true, true);
console.log(e.detail);
});
Container Events
Events that can be monitored at the container level.
Example:
$('#search-results').on('SearchResult', function(e) {
new FSToastr({
message: 'Search Results updated',
type: 'success'
}, true, true);
console.log(e.detail);
});
Global placeholders
Accessible across all portal pages featuring a placeholder picker (excluding the Head and Custom stylesheet pages).
Requester
Departments
Service Desk
Portal home
Global placeholders apply here alongside these page-specific placeholders.
Cards
Announcement
Announcements home
Global placeholders apply here alongside these page-specific placeholders.
Announcements
Announcement view
Global placeholders apply here alongside these page-specific placeholders.
Announcement
Solutions home
Global placeholders apply here alongside these page-specific placeholders.
Categories
Solution category home
Global placeholders apply here alongside these page-specific placeholders.
Folders
Articles
Articles list
Global placeholders apply here alongside these page-specific placeholders.
Article List
Other Folders
Article view
Global placeholders apply here alongside these page-specific placeholders.
Article View
Ticket details
Global placeholders apply here alongside these page-specific placeholders.
Ticket Details
Requested catalog items
Attachments
Associated assets
Ticket list
Global placeholders apply here alongside these page-specific placeholders.
Ticket Details
Pending approvals
Global placeholders apply here alongside these page-specific placeholders.
Pending Approvals
Common Asks
Changing the hero banner of the home page
Hero banner background image:
#hero-banner
{
background-image
:
url
(
'https://example.com/your-banner.jpg'
)
!important
;
}
.hero-banner-container
,
.hero-banner-container
:before
{
background
:
none
!important
;
}