Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jaichandra authored and Jai Chandra committed Sep 1, 2016
1 parent 4e0c402 commit fb8d7e6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# JS Beautifier
# JS Beautifier (With Handlebars update)
[![Build Status](https://img.shields.io/travis/beautify-web/js-beautify/master.svg)](http://travis-ci.org/beautify-web/js-beautify)
[![Build status](https://ci.appveyor.com/api/projects/status/5bxmpvew5n3e58te/branch/master?svg=true)](https://ci.appveyor.com/project/beautify-web/js-beautify/branch/master)
[![NPM version](https://img.shields.io/npm/v/js-beautify.svg)](https://www.npmjs.com/package/js-beautify)
Expand All @@ -7,6 +7,22 @@

[![NPM stats](https://nodei.co/npm/js-beautify.svg?downloadRank=true&downloads=true)](https://www.npmjs.org/package/js-beautify)

# Why this fork
Original js-beautify handlebars formatting breaks if handlebars comments contain handlebars tags `{{...}}`. This fork adds support for including handlebars tags inside comments without breaking formatting. Long commenting standard (`{{!--...--}}`) needs to be used for formatting to work with inline tags.

Example
```handlebars
{{!--
foo partial comments
Example:
{{> foo-partial}}
--}}
```

Everything below this is original documentation

---


This little beautifier will reformat and reindent bookmarklets, ugly
JavaScript, unpack scripts packed by Dean Edward’s popular packer,
Expand Down
9 changes: 7 additions & 2 deletions js/lib/beautify-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,14 @@
} else if (comment.indexOf('<!--') === 0) { // <!-- comment ...
delimiter = '-->';
matched = true;
} else if (comment.indexOf('{{!') === 0) { // {{! handlebars comment
delimiter = '}}';
} else if (comment.indexOf('{{!--') === 0) { // {{!-- handlebars comment
delimiter = '--}}';
matched = true;
} else if (comment.indexOf('{{!') === 0) { // {{! handlebars comment
if (comment.length === 5 && comment.indexOf('{{!--') === -1) {
delimiter = '}}';
matched = true;
}
} else if (comment.indexOf('<?') === 0) { // {{! handlebars comment
delimiter = '?>';
matched = true;
Expand Down

0 comments on commit fb8d7e6

Please sign in to comment.