【问题标题】:How can I prettify jades output with sails.js?如何使用sails.js 美化翡翠输出?
【发布时间】:2014-04-17 11:41:47
【问题描述】:

我正在将我的sails.js 0.9 应用程序更新到 0.10。使用旧版本,我可以美化 jam 这个配置的输出:

module.exports.config = function () {
  if (sails.config.environment === 'development') {
    // Pretty print output
    sails.express.app.locals.pretty = true;
  }
};

不幸的是,这已经改变了,我不知道如何。如何使用新的sails.js 版本美化我的html 代码?

【问题讨论】:

    标签: express sails.js


    【解决方案1】:

    config/express.js

    customMiddleware: function (app) {
      app.locals.pretty = true;
    },
    

    检查节点环境,如果你只想在开发阶段美化:

    customMiddleware: function(app) {
        if(process.env.NODE_ENV === 'development') {
            app.locals.pretty = true;
        }
    },
    

    【讨论】:

    • 感谢您的回答。我已将如何检查环境阶段添加到您的答案中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多