javascript 在 Windows 中预编译 Handlebars.js 模板

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11938892/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 14:48:40  来源:igfitidea点击:

Precompiling Handlebars.js templates in Windows

javascriptnode.jstemplateshandlebars.jspre-compilation

提问by Chris Dutrow

Looking at the Handlebars.jsdocumentation for precompilation.

查看Handlebars.js文档以进行预编译。

The instructions are for OSX. Can this be done on Windows as well?

这些说明适用于 OSX。这也可以在 Windows 上完成吗?

If so, when they say to "install node and npm" does "node" refer to "node.js"?

如果是这样,当他们说“安装 node 和 npm”时,“node”是指“ node.js”吗?

回答by s.ermakovich

  1. Install Node.js for Windows from here: http://nodejs.org/download/.
  2. Run in the command prompt:

    npm install handlebars -g
    
  1. 从这里安装适用于 Windows 的 Node.js:http: //nodejs.org/download/
  2. 在命令提示符下运行:

    npm install handlebars -g
    

Now you can use the following syntax in the command prompt:

现在您可以在命令提示符中使用以下语法:

handlebars <input> -f <output>

,where <input>is an original template file name, and <output>is a pre-compliled template file name.

,其中<input>是原始模板文件名,<output>是预编译的模板文件名。

Example:

例子:

handlebars person.hbr -f person.js

车把 person.hbr -f person.js

回答by pjlammertyn

In visual studio you have 2 options:

在 Visual Studio 中,您有 2 个选择:

1) using a bundle transform from System.Web.Optimization

1) 使用 System.Web.Optimization 的捆绑转换

2) using a postbuild event in visual studio (requires nodejs)

2)在visual studio中使用postbuild事件(需要nodejs)

see Gist

要点

回答by Paul Tyng

It seems like ASP.NET Web Tools 2012.2 has built in handlebars support(from Scott Hanselman's blog):

似乎 ASP.NET Web Tools 2012.2内置了把手支持(来自 Scott Hanselman 的博客):

Syntax Highlighting for client side templating languages within the HTML editor like:

  • CoffeeScript
  • Mustache
  • Handlebars
  • JsRender

HTML 编辑器中客户端模板语言的语法高亮显示,例如:

  • 咖啡脚本
  • 胡子
  • 车把
  • 渲染器