How to use custom function in ejs files

92 Views Asked by At

Using node.js and hexo log I want to add a function to the one of the ejs files like post-details.ejs:

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

the getSomething function is my custom function which I'm unable to find a solution to use it inside the ejs file ...

I created a plugin and I extend the helper as the documents of hexo said but I get an error which says cannot find getSomething function...

How can I simply use a custom function in ejs files ?

1

There are 1 best solutions below

0
Harshit Goyal On

You need to customize your syntax.

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

I think this should work.