Posted by: R Manimaran | December 12, 2014

SharePoint 2013: Using HandleBars.js in SharePoint –Part 3

In Part1, we have seen how to create a Handlebars template and use it SharePoint 2013 REST API output.

In Part2, we have seen how to format a SharePoint date time value using Momemt.js

In this article let us see if we have a Lookup Field column in the list.

I have created a new SharePoint List named “Domain”. In the “Employees” List I have added the title column of the Domain list as a Lookup Field. Below is the view of the Employees list after adding my Lookup column.


For the Lookup column the REST API JSON output will be different.

REST API URL Endpoint:


The JSON output for the above will be like below. Inside the Domain node we are having the title value of the Lookup field.

JSON output

We need to include the above Lookup field in the HandleBars template. So our updated template will be as below.

<!-- Handlebar Js Template Starts Here -->
<script id="employees-template" type="text/x-handlebars-template">
<th>Employee Name</th>
<td>{{FormatDate Created}}</td>
<td>{{FormatDate Modified}}</td>

Helper Function for format date

Handlebars.registerHelper("FormatDate", function (date) {
var format = 'M/DD/YYYY';
return moment(date.toString()).format('LL');

On running this script we will have the below output in the page.


Happy coding..


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: