Precompiling Handlebars.js templates in Windows

▼魔方 西西 提交于 2019-12-02 22:00:54
  1. Install Node.js for Windows from here: http://nodejs.org/download/.
  2. Run in the command prompt:

    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.

Example:

handlebars person.hbr -f person.js

In visual studio you have 2 options:

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

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

see Gist

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

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

  • CoffeeScript
  • Mustache
  • Handlebars
  • JsRender
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!