【问题标题】:How to use custom function in ejs files如何在 ejs 文件中使用自定义函数
【发布时间】:2022-10-14 23:02:15
【问题描述】:

使用 node.js 和 hexo log 我想向其中一个 ejs 文件添加一个函数,例如 post-details.ejs:

<div class="post-date info-break-policy">
   <i class="far fa-calendar-minus fa-fw"></i><%- __('publishDate') %>:&nbsp;&nbsp;
         <%- getSomething() %>
</div>

getSomething 函数是我的自定义函数,我无法在 ejs 文件中找到使用它的解决方案...

我创建了一个插件,并按照 hexo 文档的说明扩展了帮助程序,但是我收到一个错误,提示找不到 getSomething 函数......

如何在 ejs 文件中简单地使用自定义函数?

【问题讨论】:

    标签: node.js hexo


    【解决方案1】:

    您需要自定义语法。

    <div class="post-date info-break-policy">
       <i class="far fa-calendar-minus fa-fw"></i><%- __('publishDate') %>:&nbsp;&nbsp;
             <% getSomething() %>
    </div>
    

    我认为这应该有效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-01
      • 2017-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多