$p("render") takes in a Mustache.js template and the item metadata returned in our JSON response, and outputs the HTML needed for each item to be displayed in the specified area. 


You'll find more details on how to use this function in our widget rendering guide.


Template Configuration

You may not want to use {{ and }} brackets due to collision with Google Tag Manager or another other sort of template you have on your site. In that case, you can configure the brackets to use an arbitrary set of characters by passing in an array containing string expression for a custom left bracket and right bracket.


// Note that we are using '<%' and '%>' as a substitute to '{{' and '}}'
var template = '<div>' +
  '<a href="{%url%}"><img src="{%thumbnail%}"><p><%title%></p></a>' +
  '<p>{%description%}</p>' +
  '</div>'
  
var item = {
  url: "www.google.com",
  title: "google",
  description: "search engine",
  thumbnail: "www.google.com/favicon.ico"
}

// You can configure the left and right bracket by passing in array of string in which first element and second element correspond to left and right brackets respectviely.
$p("render", template, item, function(result){return result}, ['{%','%}'])

// if you don't want to define the callback,
$p("render", template, item, undefined, ['{%','%}'])