最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Use EJS templates with sails.js - Stack Overflow

programmeradmin2浏览0评论

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: .html But I don't understand why they ask to download the script ejs_production.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./getting_started.html But I don't understand why they ask to download the script ejs_production.js...

Share Improve this question asked Jul 17, 2014 at 20:34 VadorequestVadorequest 18.1k27 gold badges129 silver badges231 bronze badges 4
  • ejs is the default templating in engine in sails.js. You don't need to do any thing to start working with it. – Mahammad Adil Azeem Commented Jul 18, 2014 at 5:13
  • I have found how to use client side templates, but I still don't understand how tu use them from the server side. – Vadorequest Commented Jul 18, 2014 at 6:05
  • I can't understand your point of using them on server side.. – Mahammad Adil Azeem Commented Jul 18, 2014 at 7:29
  • Because I want to use a template inside another template and I prefer doing so in the server side instead. – Vadorequest Commented Jul 18, 2014 at 8:01
Add a ment  | 

1 Answer 1

Reset to default 6

assets/templates is used for JST

and,

Example is used client side


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

views/header.ejs

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

views/layout.ejs

<body>
<% include header %>

...

extends? (Japanese) ※ roundabout

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


Both of Server Side and Client Side ?

sorry. no idea about it...

assets/mon/header.ejs

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

views/layout.ejs

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

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

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

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

发布评论

评论列表(0)

  1. 暂无评论