Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make the linker in Sails js work with Jade?

Tags:

pug

sails.js

I have followed the instructions here yet I couldn't get the linker to work with Jade. If, however I use ejs instead, it does work (exactly the same app, apart from the jade/ejs files of course). Am I missing something?

like image 623
WagnerMatosUK Avatar asked Jan 04 '14 16:01

WagnerMatosUK


People also ask

How does sails JS work?

Sails is built on Node. js, a popular, lightweight server-side technology that allows developers to write blazing fast, scalable network appliations in JavaScript. Sails uses Express for handling HTTP requests, and wraps socket.io for managing WebSockets.

Is sails JS framework?

Sails is the most popular MVC framework for Node. js, designed to emulate the familiar MVC pattern of frameworks like Ruby on Rails, but with support for the requirements of modern apps: data-driven APIs with a scalable, service-oriented architecture.

What is sails Nodejs?

js (or Sails) is a model–view–controller (MVC) web application framework developed atop the Node. js environment, released as free and open-source software under the MIT License. It is designed to make it easy to build custom, enterprise-grade Node. js web applications and APIs.


2 Answers

I'm assuming you have done the following:

  • Created a new project with linker and jade as template

    sails new <project-name> --template=jade --linker
    
  • you manually added jade

    cd <project-name>
    npm install jade --save
    
  • (optionally) removed the dependency to ejb in the package.json file.

Is that correct?

In that case, I've received a warn that says:

warn: Automatic asset linking is not implemented for the `jade` view engine at this time. You must modify the Gruntfile yourself for this feature to work.

This looks like an old and outdated message, as I looked to the grunt file and everything look like it was prepared for linking to jade.

So then, I've changed the layout.jade file in the views folder to:

  • Remove script(src="/js/sails.io.js")
  • and add the placeholders to inject:

    // SCRIPTS
    // SCRIPTS END
    // STYLES
    // STYLES END
    

Then I made a "sails lift" and the scripts in the javascript files in the public/linker/js folder were injected.

BTW: I'm using sails v0.9.9

Hope this helps.

like image 195
Diego Pamio Avatar answered Oct 21 '22 03:10

Diego Pamio


Being new to sails and jade i found the following link helpful. Turns out you need to go into config > views.js & then change the "engine:" from saying 'ejs' to 'jade'

After doing this you'll have to also install jade as a dependency:

npm install jade --save

sails can't find layout.jade

like image 29
ceotoolsuite Avatar answered Oct 21 '22 02:10

ceotoolsuite