javascriptnode.jshandlebars.jsghost

Remove the comma from Ghost Handlebars Template?


When traverse the tags, suddenly have comma. This may not be willing to see the effect. I am try remove the comma, but is there any way to remove ,? I saw the Ghost blog Document when not quite sure how to remove comma.

Look at the picture:

enter image description here

post.hbs:

<span class="post-meta">
      {{#if tags}} 
          {{tags}} 
      {{/if}}
</span>

Solution

  • Not sure what problems you was having.

    But I've knocked up quick snippet that shows it working.

    var source = document.getElementById("template").innerHTML; 
    var template = Handlebars.compile(source); 
    
    var data = {
      tags: ["Spring Boot", "MyBatis", "CRUD"]
    };
    
    
    document.getElementById("output").innerHTML = template(data);
    <script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.11/handlebars.js"></script>
    
    <script id="template" type="text/x-handlebars-template">
      <span class="post-meta">
        {{#tags}}
        {{.}}&nbsp;
        {{/tags}}
      </span>
    </script>
    
    <div id="output">
    </div>