Sara Ree
Sara Ree

Reputation: 3543

How to use custom function in ejs files

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 ?

Upvotes: 0

Views: 123

Answers (1)

Harshit Goyal
Harshit Goyal

Reputation: 19

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.

Upvotes: 1

Related Questions