LoginSignup
4
4

More than 3 years have passed since last update.

EJSで別ファイルに定義したEJSの関数を呼び出す

Posted at

備忘録として。

共通関数ファイル

myFunctions.ejs
<%
myFunc = {
  test: function(){ return "hello"; },
  hoge: function(str){ return str; }
}
%>

Viewファイルとか

index.html.ejs
<% include('./myFunctions.ejs') -%>
<%- myFunc.test() %>

出力

hello
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4