简体   繁体   中英

Use EJS templates with sails.js

I can't figure out how to use EJS templates with the framework sails.js.

Here is what I've tried:

ejs = require('ejs')

new ejs({url: 'assets/linker/templates/box.ejs'}).render(data);

But I get object is not a function

Any example? I tried to follow the example here: http://embeddedjs.com/getting_started.html But I don't understand why they ask to download the script ejs_production.js ...

assets/templates is used for JST

and,

Example is used client side


server side include ? https://github.com/visionmedia/ejs#includes

views/header.ejs

<header>
    <h1>title: <%- title %> </h1>
</header>

views/layout.ejs

<body>
<% include header %>

...

extends? (Japanese) ※ roundabout

http://nantokaworks.com/node-advent2013-day20/


Both of Server Side and Client Side ?

sorry. no idea about it...

assets/common/header.ejs

<header>
    <h1>title: <%- title %> </h1>
</header>

views/layout.ejs

<body>
 <% include ../assets/common/header %>

It may be used in both in this way...

new ejs({url: 'assets/common/header.ejs'}).render(data);

or grunt-contrib-copy, folder views/common to assets/common

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM