Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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...

like image 922
Vadorequest Avatar asked Jul 20 '26 14:07

Vadorequest


1 Answers

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

like image 172
kamiyam Avatar answered Jul 23 '26 04:07

kamiyam