0

Have an item display template in SharePoint 2013. The returned property has multiple entries and I'm trying to format them with a pipe between them.Here is the code that I put in the html file.

function makePretty(prop){
  var tags = prop.split("\n");
  for(var i = 0;i<tags.length;i++){
    var str=tags[i];
    ...

For some reason when the html file is uploaded and processed into js it adds quotes to the str assignment.

var str="tags[i];"

Otherwise it all works, I just end up with output literally like this.

tags[i]; | tags[i]; | tags[i];

When I expected something like this

My tag1 | Tag2 | Value of tag 3

Any idea what is going on? How do I put that kind of function into a display template and tell SP to leave it alone?

0

Not sure if it is the only or correct answer, but we took the same code outside of a function and it works just fine. So

var tags = prop.split("\n");
  for(var i = 0;i<tags.length;i++){
    var str=tags[i];
   ...

Evidently display templates don't want to let functions have ambiguously typed things?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.