I use Handlebars to load HTML content from a javascript file. Here is the code that puts text into an HTML div.

var mainInfo = "{{{header}}} {{{describtion}}} {{{sentence3}}}"; var template = Handlebars.compile(mainInfo); var data = template({ header: "<h1>Powerful business</h1>", describtion: '<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit.Donec turpis neque, sodales a faucibus at, viverra luctus urna. Suspendisse dignissim neque dui, in tincidunt arcu.</p>' }); document.getElementById ("maintext").innerHTML += data; 

But when I duplicate the same code with different variable names, in order to load content to other areas of the web page, everything stops working.

By experience, I realized that it is still possible to create a new variable, but it is worth assigning an expression to it handlebars, for example:

  var cerviceContent = "{{newheader}}} {{{content}}}; 

And the text disappears from everywhere. Why and how to fix it?

Closed due to the fact that off-topic participants Dmitriy Simushev , user207618, Ivan Pshenitsyn , user194374, sercxjo 21 Aug '16 at 7:32 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - Dmitriy Simushev, Community Spirit, Ivan Pshenitsyn, Community Spirit, sercxjo
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    var cerviceContent = "{{{newheader}}} {{{content}}}"; the code is not parsed due to a missing opening brace and a closing quote - Igor
  • @Igor Thank you very much. If issue as an answer, I can mark as true. - Rumata pm

1 answer 1

The code is not parsed due to the missing opening brace and closing quote:

 var cerviceContent = "{{{newheader}}} {{{content}}}";