【问题标题】:Posts variable empty帖子变量为空
【发布时间】:2015-08-23 16:37:15
【问题描述】:

我按照这篇文章http://support.ghost.org/create-custom-page-template/ 中描述的步骤创建了一个自定义页面。

我想在此页面中显示我所有博客文章的索引。没有描述,只有标题。

所以,我在http://myadress/test 上创建了一个静态页面 并在我的根文件夹中创建一个 page-test.hbs。在这个文件中我写了这段代码来做一个测试:

{{!< default}}
<ol class="posts">
  {{#foreach posts}}
  <table>
    <thead>
        <tr>
            <th>test</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>test</td>
        </tr>
    </tbody>
</table>
  {{/foreach}}
</ol>
  <table>
    <thead>
        <tr>
            <th>test</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>test</td>
        </tr>
    </tbody>
</table>

foreach 中的代码没有被执行。但外面是。

现在,我是 Ghost 的新手,所以帖子变量可能什么都没有,对吧?如何将帖子列表放入其中?

提前致谢(:

【问题讨论】:

    标签: handlebars.js blogs ghost-blog


    【解决方案1】:

    您实际上需要在其中放置一些帖子数据/属性。您所做的只是创建帖子范围.ie

    {{title}} {{content}} {{published_at}} etc....
    

    在此处查看所有属性的列表:The post context

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-10-11
      • 2019-08-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-20
      相关资源
      最近更新 更多