Sails JS with EJS, but a linker for compiling public steering templates

I'm a little new to Node and javascript frameworks, so please bear with me:

I was looking for a suitable combination of front-end interface (MVC) frameworks to work with Node, and currently I decided to use SailsJS / EmberJS to create a template that I can play with and possibly use for future projects.

SailsJs (from the finished application) uses EJS to compile background views. EmberJs (the default starter kit) uses rudders to compile front-end views.

I want to preserve the template language (EJS), as with one exception to the SailsJS linker. He is currently compiling public templates like "jst.js" which are not compatible with descriptors. I would like to change this so that "jst.js" will contain compiled templates using rudders, so they will be served by the front interface (ember app), which will be ready for use.

I assume that this will require an additional Node library. How do I configure Gruntfile.js to use this library so that the linker can output compiled templates to a shared directory?

+3
source share
3 answers

EJS Sails Ember. Ember , . Sails EJS ; Ember REST API. , , , Ember App Kit . , EAK - .

0

grunt-ember - dev: . , :

var pipeline = require('../pipeline');

module.exports = function(grunt) {

grunt.config.set('emberTemplates', {
        compile: {
            options: {
                amd: true,
                templateBasePath: pipeline.templateBasePath
            },
            files: {
                '.tmp/public/jst.js': pipeline.templateFilesToInject
            }
        }
});

grunt.loadNpmTasks('grunt-ember-templates');
};
0

, , ...

Check https://github.com/dgeb/grunt-ember-templates for this "additional node library"

and see http://sailsjs.org/#/documentation/concepts/Assets/TaskAutomation.html?q=task-configuration for setting up the task.

How I worked was to create the following file in tasks\config\emberTemplates

var pipeline = require('../pipeline');

module.exports = function(grunt) {

    grunt.config.set('emberTemplates', {
        dev: {
            compile: {
                options: {
                    amd: true,
                    templateBasePath: pipeline.templateBasePath
                },
                files: {
                    '.tmp/public/jst.js': pipeline.templateFilesToInject
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-ember-templates');
};

And change tasks\pipeline.jsto these lines

var templateBasePath = 'assets/templates/';
var templateFilesToInject = [
  templateBasePath + '**/*.hbs' //Note that whatever is replaced by '**/' will be included in the template name (necessary for defining components see http://emberjs.com/guides/components/defining-a-component/).
];

module.exports.templateFilesToInject = templateFilesToInject;
module.exports.templateBasePath = templateBasePath;

and, of course, put your templates in assets/templateswith the extension .hbs.

-1
source

All Articles