In EJS template engine, how do I “include” a footer?

前端 未结 6 1459
萌比男神i
萌比男神i 2020-12-09 01:42

Let\'s say I saved a snipplet of a footer. How do I \"include\" that in my current template?

6条回答
  •  星月不相逢
    2020-12-09 01:46

    the right syntax is <%- include('', ) %>

    include is a function Includes are relative to the template with the include call. (This requires the 'filename' option.) For example if you have "./views/users.ejs" and "./views/user/show.ejs" you would use <%- include('user/show'); %>.

    You'll likely want to use the raw output tag (<%-) with your include to avoid double-escaping the HTML output.

    提交回复
    热议问题