Closes #13. Add Handlebars support.
This commit is contained in:
parent
58a375f8b6
commit
b530eda6e3
|
@ -1,13 +1,13 @@
|
|||
# [atom-beautify](https://github.com/donaldpipowitch/atom-beautify)
|
||||
|
||||
[Beautify](https://github.com/einars/js-beautify) HTML, CSS and JavaScript in Atom.
|
||||
[Beautify](https://github.com/einars/js-beautify) HTML (including Handlebars), CSS and JavaScript in Atom.
|
||||
|
||||
*Attention*: A different package with a similar name exist. Maybe you want to visit this one: [Beautifier](https://atom.io/packages/atom-beautifier).
|
||||
|
||||
## Usage
|
||||
|
||||
Open the [Command Palette](https://github.com/atom/command-palette), and type `Beautify`.
|
||||
This will beautify JS, HTML or CSS files.
|
||||
This will beautify JS, HTML (including Handlebars), or CSS files.
|
||||
XML is supported as an experimental feature.
|
||||
|
||||
It will only beautify selected text, if a selection is found - if not, the whole file will be beautified.
|
||||
|
@ -32,6 +32,8 @@ Edit your `.jsbeautifyrc` file in any of the following locations:
|
|||
|
||||
You can see examples of both way inside [`examples/`](https://github.com/donaldpipowitch/atom-beautify/tree/master/examples)
|
||||
|
||||
*Comments are supported in `.jsbeautifyrc` thanks to [strip-json-comments](https://github.com/sindresorhus/strip-json-comments).*
|
||||
|
||||
## Contributing
|
||||
|
||||
[See all contributors on GitHub](https://github.com/donaldpipowitch/atom-beautify/graphs/contributors).
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
{
|
||||
"indent_size": 2,
|
||||
"indent_char": " ",
|
||||
"other": " ",
|
||||
"indent_level": 0,
|
||||
"indent_with_tabs": false,
|
||||
"preserve_newlines": true,
|
||||
"max_preserve_newlines": 2,
|
||||
"jslint_happy": true
|
||||
"jslint_happy": true,
|
||||
"indent_handlebars": true
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
{{#if}}
|
||||
{{#each}}
|
||||
{{#if}}
|
||||
content
|
||||
{{/if}}
|
||||
{{#if}}
|
||||
content
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{/if}}
|
|
@ -19,6 +19,7 @@ var knownOpts = {
|
|||
'indent_char': String,
|
||||
'indent_level': Number,
|
||||
'indent_with_tabs': Boolean,
|
||||
'indent_handlebars': Boolean,
|
||||
'preserve_newlines': Boolean,
|
||||
'max_preserve_newlines': Number,
|
||||
'space_in_paren': Boolean,
|
||||
|
@ -229,8 +230,14 @@ function beautify() {
|
|||
|
||||
}, {}, selection);
|
||||
|
||||
// Clean
|
||||
options = cleanOptions(options, knownOpts);
|
||||
|
||||
// TODO: Clean.
|
||||
// There is a bug in nopt
|
||||
// See https://github.com/npm/nopt/issues/38#issuecomment-45971505
|
||||
//console.log('pre-clean', JSON.stringify(options));
|
||||
//options = cleanOptions(options, knownOpts);
|
||||
//console.log('post-clean', JSON.stringify(options));
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
|
@ -238,6 +245,8 @@ function beautify() {
|
|||
case 'JavaScript':
|
||||
text = beautifyJS(text, getOptions('js', allOptions));
|
||||
break;
|
||||
case 'Handlebars':
|
||||
defaultOptions.indent_handlebars = true; // jshint ignore: line
|
||||
case 'HTML (Liquid)':
|
||||
case 'HTML':
|
||||
case 'XML':
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
"dependencies": {
|
||||
"emissary": "^1.0.0",
|
||||
"extend": "^1.2.1",
|
||||
"js-beautify": "~1.4.2",
|
||||
"nopt": "^2.2.1",
|
||||
"js-beautify": "~1.5.1",
|
||||
"nopt": "^3.0.0",
|
||||
"lodash": "2.4.1",
|
||||
"shelljs": "^0.3.0",
|
||||
"strip-json-comments": "^0.1.3"
|
||||
|
|
Loading…
Reference in New Issue