Last Updated: February 25, 2016
·
2.279K
· develoser

Handlebars precompiler plugin Sublime Text 2

Hi all!

Today I want to share with you a little plugin to can compile Handlebars templates in ST2.

Install:

a) First of all you need to have installed and running Nodejs http://nodejs.org/
b) Next, install the Handlebars npm package:

$ npm install -g handlebars

c) Finally just clone/download the following repository into your Packages folder as Handlebars-ST2-Precompiler: https://github.com/develoser/Handlebars-ST2-Precompiler

Usage

a) Open a template with the default extension: .hb, .handlebars or .html.
Note: You can add more extensions as you need.

b) If all are ok on right click you will see a new option in the context menu called: Precompile with Handlebars, select this option.

c) A new precompiled file is created and opened in a new tab (with a .js extension, the same is also configurable).

d) And thats all!

Settings

The plugin comes with a few default options like following:

{
    "handlebars_exec" : "handlebars",
    "allowed_extensions" : [".hb", ".handlebars", ".html"],
    "compiler_options" : ["-m", "-f"],
    "compiled_extension" : ".js"
}

handlebars_exec: This is the default command to run Handlebars allowed_extensions: This array contains all the allowed extensions by default. If your templates have a different one please add it here.
compiler_options: This array contains the default options for Handlebars. Default are:-m: Minimize and -f: ouput file.
compiled_extension: Finally, if you want a different file for the output change it here.

You can modify any those options as you want.

3 Responses
Add your response

Great! i'm gonna test it right now. Thanks.

over 1 year ago ·

@datreee Cool buddy, any issues please ping me.

over 1 year ago ·

The only thing i add to the core plugin is the posibility to create my own path for compilated .js when i've all setted up i'll share with the comunity. Cyas.

over 1 year ago ·