- Notifications
You must be signed in to change notification settings - Fork48
Fullest Handlebars.js templating support for Sublime Text 2 / 3. Also drives syntax colouring on Github and in Visual Studio Code. Install from:https://packagecontrol.io/packages/Handlebars.
License
daaain/Handlebars
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
- Colours of Handlebars expressions are selected to be in contrast with the surrounding HTML.
- Handlebars expressions get syntax highlighting in HTML attributes.
- Parameters passed to block expressions get syntax highlighting too.
- Works both with individual template files and inline templates in script tags.
- Key bindings for
{{! Handlebars comments }}
(Sublime only) - Tab triggers for
if
→{{#if }}
ifel
→{{#if }} {{else}}
el
→{{else}}
elif
→{{else if }}
un
→{{#unless }}
ea
→{{#each }}
wi
→{{#with }}
par
→{{> }}
(for partials)x-temp
→<script type="text/x-handlebars" data-template-name="$1">
(inline script tag in HTML files using the Ember recommendeddata-template-name
attribute)x-id
→<script type="text/x-handlebars-template">
(inline script tag in HTML files using the legacyid
attribute)
Since (as of February 2017) the syntax definitions in this repository are driving the highlights onGithub and inVisual Studio Code, it's fair game to open issues related to either of these 😺
It's a great JavaScript templating engine, based onMustache, but amongst others adding the ability to precompile templates and to create custom helpers.
Official website:handlebarsjs.com
Get it throughSublime Package Control.
If you haven't used it yet, just install it from the link above and then:
- PressShift +Cmd +P (OS X) orShift +Ctrl +P (Windows)
- Type
install
, to bring up thePackage Control: Install Package
option, and press Enter - Look for
Handlebars
, and press Enter to install it. - Choose
Handlebars
in the bottom right corner with one of your template files open (or in case you have inline templates use Handlebars instead of HTML, it's gracefully extending it so you shouldn't lose anything) - Profit
Package Control will also auto-update the package from this point on!
Problem: when closing an HTML tag, the tag name doesn't get auto-completed after typing/ (or when using theCmd +Alt +. (OS X) shortcut anywhere), even though this is the default behaviour with the HTML package.
Solution: installing theTag package re-instates these functionalities and seems to be working well with this one.
Sublime: HTML tag pair doesn't get highlighted (#48)
Problem: moving the cursor over an HTML tag doesn't highlight its pair.
Solution: installing theBracketHighlighter package nicely solves the problem and adds much more powerful bracket matching than the built-in one.
Sublime: Expand selection to tag doesn't work (#47)
Problem: Expanding selection to tag doesn't work (Sublime command:expand_selection {"to": "tag"}
).
Solution: if you install theEmmet package you can use theMatch Tag Pair
functionality by pressingCtrl +D (OS X) orCtrl +Shift +A (Windows).
Sublime:.sublime-build
in the build system menu (#73)
Problem: a useless and confusing item named.sublime-build
is added to the build system menu. This is because the package internally uses a custom build configuration to be able to target both Atom and Sublime and this gets exposed. Though it's only needed for development, Sublime doesn't seem to offer an option to hide this as the package gets installed.
Solution: delete the file from the package by runningzip -d Handlebars.sublime-package ".sublime-build"
in the folder it's installed or by any other means.
I've recently stopped heavily using Handlebars at my day job and became a father, so any contributions are more than welcome! I'm still using Github so will make sure to keep on being responsive on issues and pull requests.
There are some sample templates intest/
folder. It's possible to see the different supported and yet to be implemented use cases there.
If you want to work on the package you should install PackageDev eitherfrom Github or from Package Control. With that you can edit the JSON version (grammars/Handlebars.json
) and let it export the Plist (grammars/Handlebars.tmLanguage
) with the ST Build System.
Sublime Text does not use thePlist format (grammars/Handlebars.tmLanguage
); rather, it uses the Sublime-Syntax file (grammars/Handlebars.sublime-syntax
). This file was originally generated with thePlugin Development: Convert Syntax to .sublime-syntax
Sublime command, but it has since diverged in order to fix a Sublime Text specific bug (#110). Ideally, the two versions will track each other, but Pull Requests which effect only one version are still appreciated.
The nicest development setup I found so far is to have the package installed via Package Control and then symlinking the development Git repo toSublime settings folder > Packages
, which then overrides the installed one so you can toggle between them easily.
Another great trick I found out about recently is theShow scope name
shortcut (Shift +Ctrl +P (OS X) orShift +Ctrl +Alt +P (Windows)) which will display the language scope on the status bar based on where your cursor is. If you're getting tired of pressing all these keys all the time, there are a few brilliant packages which do this automatically like the more subtleScopeAlways or the full onScopeHunter – note: both need to be activated via the Command Palette.
This package does not offer any Handlebars precompilation functionality to keep things simple, but you can use RubyGuard (which is a file system watcher) andGuard-Steering (a Handlebars precompiler from yours truly) to have all templates precompiled as you save them.
There's also aGuard package for Sublime if you want integration, but I don't personally use this as I'm happy with Guard running in a terminal window I can access from anywhere.
There are of course Node.js / Grunt / Gulp based compilers too (like this andthis), but I haven't personally used any yet for precompilation.
Adapted from the greatsublime-text-handlebars package by Nicholas Westlake.
Thanks a lot to all thegenerous contributors!
(The MIT License)
Permission is hereby granted, free of charge, to any person obtaininga copy of this software and associated documentation files (the'Software'), to deal in the Software without restriction, includingwithout limitation the rights to use, copy, modify, merge, publish,distribute, sublicense, and/or sell copies of the Software, and topermit persons to whom the Software is furnished to do so, subject tothe following conditions:
The above copyright notice and this permission notice shall beincluded in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANYCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THESOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
About
Fullest Handlebars.js templating support for Sublime Text 2 / 3. Also drives syntax colouring on Github and in Visual Studio Code. Install from:https://packagecontrol.io/packages/Handlebars.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors15
Uh oh!
There was an error while loading.Please reload this page.