<bdo id='2YdUj'></bdo><ul id='2YdUj'></ul>
  1. <i id='2YdUj'><tr id='2YdUj'><dt id='2YdUj'><q id='2YdUj'><span id='2YdUj'><b id='2YdUj'><form id='2YdUj'><ins id='2YdUj'></ins><ul id='2YdUj'></ul><sub id='2YdUj'></sub></form><legend id='2YdUj'></legend><bdo id='2YdUj'><pre id='2YdUj'><center id='2YdUj'></center></pre></bdo></b><th id='2YdUj'></th></span></q></dt></tr></i><div id='2YdUj'><tfoot id='2YdUj'></tfoot><dl id='2YdUj'><fieldset id='2YdUj'></fieldset></dl></div>

      <small id='2YdUj'></small><noframes id='2YdUj'>

      <legend id='2YdUj'><style id='2YdUj'><dir id='2YdUj'><q id='2YdUj'></q></dir></style></legend>
    1. <tfoot id='2YdUj'></tfoot>

      grunt-contrib-handlebars - 输出与我运行把手 npm 任务时不同

      grunt-contrib-handlebars - Output is different than when I run the handlebars npm task(grunt-contrib-handlebars - 输出与我运行把手 npm 任务时不同)
        <tfoot id='VIrIR'></tfoot>
      • <legend id='VIrIR'><style id='VIrIR'><dir id='VIrIR'><q id='VIrIR'></q></dir></style></legend>
            <tbody id='VIrIR'></tbody>

                <bdo id='VIrIR'></bdo><ul id='VIrIR'></ul>

                <i id='VIrIR'><tr id='VIrIR'><dt id='VIrIR'><q id='VIrIR'><span id='VIrIR'><b id='VIrIR'><form id='VIrIR'><ins id='VIrIR'></ins><ul id='VIrIR'></ul><sub id='VIrIR'></sub></form><legend id='VIrIR'></legend><bdo id='VIrIR'><pre id='VIrIR'><center id='VIrIR'></center></pre></bdo></b><th id='VIrIR'></th></span></q></dt></tr></i><div id='VIrIR'><tfoot id='VIrIR'></tfoot><dl id='VIrIR'><fieldset id='VIrIR'></fieldset></dl></div>
              • <small id='VIrIR'></small><noframes id='VIrIR'>

                本文介绍了grunt-contrib-handlebars - 输出与我运行把手 npm 任务时不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                提前感谢您的时间和帮助.

                我正在尝试使用 grunt-contrib-handlebars 预编译把手 (.hbs) 模板

                当我运行运行任务时,我最终得到了这个:

                this["JST"] = this["JST"] ||{};this["JST"]["app/templates/err.hbs"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {this.compilerInfo = [4,'>= 1.0.0'];helpers = this.merge(helpers, Handlebars.helpers);数据 = 数据 ||{};var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;缓冲区+=

                错误:";if (stack1 = helpers.error) { stack1 = stack1.call(depth0, {hash:{},data:data});}否则 { stack1 = depth0.error;stack1 = typeof stack1 === functionType ?stack1.apply(depth0) : stack1;}缓冲区 += 转义表达式(stack1)+ "</div>";返回缓冲区;});

                但是,如果我从终端运行 npm 车把模块,我会得到:

                (function() {var 模板 = Handlebars.template,模板 = Handlebars.templates = Handlebars.templates ||{};模板['err.hbs'] = 模板(功能(车把,深度0,助手,部分,数据){this.compilerInfo = [4,'>= 1.0.0'];helpers = this.merge(helpers, Handlebars.helpers);数据 = 数据 ||{};var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;缓冲区+=

                错误:";if (stack1 = helpers.error) { stack1 = stack1.call(depth0, {hash:{},data:data});}否则 { stack1 = depth0.error;stack1 = typeof stack1 === functionType ?stack1.apply(depth0) : stack1;}缓冲区 += 转义表达式(stack1)+ "</div>";返回缓冲区;});})();

                第二个编译模板(从终端运行)在我的应用程序中正常工作 - 但 grunt 创建的模板不能.有人可能会指出我在这里可能做错的事情的正确方向吗?

                我的 gruntfile 看起来像这样:

                车把:选项:包裹:真编译:文件:'www/js/templates.js':['app/templates/*.hbs']

                再次感谢您的帮助!

                解决方案

                原来这是使用不同版本的 Handlebars 导致的问题,其中 grunt-contrib-handlebars 版本与全局安装的 handlebars npm 模块不同.

                p>

                Thank you in advance for your time and help.

                I'm trying to precompile handlebars (.hbs) templates using grunt-contrib-handlebars

                When I run the run task I end up with this:

                this["JST"] = this["JST"] || {};
                
                this["JST"]["app/templates/err.hbs"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
                  this.compilerInfo = [4,'>= 1.0.0'];
                helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
                  var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;
                
                
                  buffer += "<div>Error: ";
                  if (stack1 = helpers.error) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
                  else { stack1 = depth0.error; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
                  buffer += escapeExpression(stack1)
                    + "</div>";
                  return buffer;
                  });
                

                However, if I run the npm handlebars module from terminal I get this:

                (function() {
                  var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
                templates['err.hbs'] = template(function (Handlebars,depth0,helpers,partials,data) {
                  this.compilerInfo = [4,'>= 1.0.0'];
                helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
                  var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;
                
                
                 buffer += "<div>Error: ";
                 if (stack1 = helpers.error) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
                 else { stack1 = depth0.error; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
                 buffer += escapeExpression(stack1)
                   + "</div>";
                 return buffer;
                 });
                })();
                

                The second compiled template (run from terminal) works correctly in my app - but the one that grunt creates does not. Could someone perhaps point me in the right direction with what I might be doing wrong here?

                My gruntfile looks like this:

                handlebars:
                       options:
                                wrapped: true
                       compile:
                                files: 'www/js/templates.js': ['app/templates/*.hbs']
                

                Thanks again for your help!

                解决方案

                Turns out this was a problem caused by using different versions of Handlebars where the grunt-contrib-handlebars version was different then the globally installed handlebars npm module.

                这篇关于grunt-contrib-handlebars - 输出与我运行把手 npm 任务时不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)
                Rails 3.1 ajax:success handling(Rails 3.1 ajax:成功处理)
                CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                Ordinals in words javascript(javascript中的序数)
                getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)

                    <tbody id='G9RyM'></tbody>
                  <i id='G9RyM'><tr id='G9RyM'><dt id='G9RyM'><q id='G9RyM'><span id='G9RyM'><b id='G9RyM'><form id='G9RyM'><ins id='G9RyM'></ins><ul id='G9RyM'></ul><sub id='G9RyM'></sub></form><legend id='G9RyM'></legend><bdo id='G9RyM'><pre id='G9RyM'><center id='G9RyM'></center></pre></bdo></b><th id='G9RyM'></th></span></q></dt></tr></i><div id='G9RyM'><tfoot id='G9RyM'></tfoot><dl id='G9RyM'><fieldset id='G9RyM'></fieldset></dl></div>

                      • <bdo id='G9RyM'></bdo><ul id='G9RyM'></ul>
                      • <tfoot id='G9RyM'></tfoot>

                        <small id='G9RyM'></small><noframes id='G9RyM'>

                      • <legend id='G9RyM'><style id='G9RyM'><dir id='G9RyM'><q id='G9RyM'></q></dir></style></legend>