Using underscore / lodash as a template engine in Sails JS

I have a one-page web application using the backbone in the client and node (Sails) on the server.

I am currently using lodash.underscore as a template engine in the client and qiwi on the server.

I want to implement pushstate with progressive enhancement. that is, the client and server will use the same template files.

This means that they will need to use the same template engine; I decided to go with underscore / lodash.

Inside Sails config \ views.js, this means that you can use the underline as a template mechanism. The problem is that I cannot figure out how to do this. I included it in my package.json package and installed

'engine': 'underscore'

Then I get an error message when starting my application - "callback function required on Function.app.engine"

If I set the qiwi, jade, ejs, etc. engine, then it will work.

Any idea what I'm doing wrong?

+4
source share
2 answers

I'm not sure that I understand exactly what you are asking, however I used underscore patterns in my server-side views with the following configuration:

In config/viewsI installed my engine in ejs:

engine: 'ejs',

And in mine Gruntfile.jsI installed:

var templateFilesToInject = [
    'linker/**/*.ejs'
];
0
source

Consolidate.js 0.3.1 Lodash 0.10.0.

Sails.js , Express Consolidate, Sails Consolidate 0.12.0-rc2. , Sails , , Underscore 0.10.0.

, Sails, , Underscore , npm i --save underscore, .

0

All Articles