从Ghost Handlebars模板中删除逗号?

时间:2018-02-02 11:55:07

标签: javascript node.js handlebars.js ghost

遍历标签时,突然有逗号。这可能不愿意看到效果。我尝试删除逗号,但有没有办法删除 <article> <!-- Banner/hero image section for Event--> <header class="my_hero_class" role="banner" itemscope itemtype="http://schema.org/WPHeader"> <meta itemprop="name" content="My Event"> <meta itemprop="description" content="Description of My Event"> <meta itemprop="keywords" content="keyword1, keyword2, keyword3"> <h1 itemprop="headline">A headline text</h1> <p itemprop="alternateHeadline">Another headline text<p> <p itemprop="creator">Artist name<p> <img itemprop="image" src="hero_image.jpg"> </header> <!-- Event section --> <section class="my_event_class" itemscope itemtype="http://schema.org/Event"> <h2 itemprop="name">Name of My Event</h2> <p itemprop="description">Description of My Event</p> <p itemprop="text">Text about My Event</p> <p itemprop="startDate" content="2016-04-21T20:00">Thu, 04/21/16 8:00 p.m.</p> <meta itemprop="startDate" content="2016-04-21T20:00"> <img itemprop="image" src="poster.jpg"> </section> <!-- Event Artist section --> <section class="my_person_class" itemscope itemtype="http://schema.org/Person"> <h2 itemprop="name">Name of Artist</h2> <p itemprop="description">Description of of Artist</p> <p itemprop="text">Text about of Artist</p> <img itemprop="image" src="artist.jpg"> </section> </article> ?当我不太确定如何删除逗号时,我看到了Uniform way to add multiple descriptive properties in Schema.org

看图片:

HTML5 & Schema.org - Structured Microdata for SEO

post.hbs:

,

2 个答案:

答案 0 :(得分:0)

在Ghost {{tags}}中是一个特殊帮助器,它输出带有完整HTML的标签列表。

您链接到的文档页面:https://themes.ghost.org/docs/tags包含如何使用传递给帮助程序的各种属性修改输出的完整详细信息。

在您的情况下,您需要将separator的值从默认的,(逗号和空格)更改为(可能)只是一个空格:

{{tags separator=" "}}

答案 1 :(得分:-1)

不确定您遇到了什么问题。

但我已经敲了快速片段,证明它有效。

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>