Yesterday we had the first Biwug Quiz. One of the questions was the following:
Display Templates require one of the following options:
- HTML
- JavaScript
- JavaScript & HTML
- XSL
Everyone has answered that you need the JavaScript and HTML file, but this isn’t correct. The correct one was number two JavaScript. To clarify the answer I will show you why you don’t need the HTML file.
The HTML file only makes the creation process of display template easier.
If you create a new site collection from the team site definition, you will only have the JavaScript files available in the master page gallery.
![JavaScript versions](https://www.eliostruyf.com/uploads/2013/10/101113_0815_Whatisrequi1.png)
The HTML versions become available once you have activated the SharePoint Server Publishing Infrastructure feature.
![JavaScript & HTML versions](https://www.eliostruyf.com/uploads/2013/10/101113_0815_Whatisrequi2.png)
If you aren’t working with the HTML file (what I don’t recommend) you will have to do some manual actions.
First of all, start by making a copy of one of the existing display templates. I choose to create a copy of the Item_TwoLines.js file.
The next step is to modify the properties for that file like this:
![Item Properties](https://www.eliostruyf.com/uploads/2013/10/101113_0815_Whatisrequi3.png)
![Item Properties](https://www.eliostruyf.com/uploads/2013/10/101113_0815_Whatisrequi4.png)
Once you have modified these properties, it is time to change the template a bit.
To start you will need to update your template URLs in the display template because the reference will be set to the old file.
|
|
Then it is up to you what you want to modify in the template, I added a text element that shows “My file extension is: FileExtension”.
This is the end result:
![Result](https://www.eliostruyf.com/uploads/2013/10/101113_0815_Whatisrequi5.png)