template rendering with node.js and backbone.js

后端 未结 9 1251
孤城傲影
孤城傲影 2021-02-01 08:20

Has anyone found a good solution for developing templates for backbone.js that can be used on the server and the client?

This is really desirable with the backbone.js hi

9条回答
  •  长情又很酷
    2021-02-01 08:42

    Here's a very simple example of rendering an Underscore/Backbone template in NodeJS. I've installed Underscore using NPM.

    var http = require('http'),
        _ = require('underscore');
    
    http.createServer(function (req, res) {
        var template = "

    <%=message%>

    " res.end(_.template( template, {message: "Hello world"})); }).listen(8080, 'localhost');

提交回复
热议问题