简体   繁体   English

将EJS模板与sails.js一起使用

[英]Use EJS templates with sails.js

I can't figure out how to use EJS templates with the framework sails.js. 我无法弄清楚如何在框架sails.js中使用EJS模板。

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 但我得到的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 ... 我试着按照这里的例子: httpejs_production.js但我不明白他们为什么要求下载脚本ejs_production.js ...

assets/templates is used for JST 资产/模板用于JST

and, 和,

Example is used client side 示例用于客户端


server side include ? 服务器端包括? https://github.com/visionmedia/ejs#includes https://github.com/visionmedia/ejs#includes

views/header.ejs 意见/ header.ejs

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

views/layout.ejs 意见/ layout.ejs

<body>
<% include header %>

... ...

extends? 扩展? (Japanese) ※ roundabout (日语)※环形交叉路口

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


Both of Server Side and Client Side ? 服务器端和客户端都有?

sorry. 抱歉。 no idea about it... 不知道它......

assets/common/header.ejs 资产/普通/ header.ejs

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

views/layout.ejs 意见/ 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 或grunt-contrib-copy,文件夹视图/资产/公共共同

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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