diff --git a/examples/nested-jsbeautifyrc/.jsbeautifyrc b/examples/nested-jsbeautifyrc/.jsbeautifyrc index feb1813..6457b98 100644 --- a/examples/nested-jsbeautifyrc/.jsbeautifyrc +++ b/examples/nested-jsbeautifyrc/.jsbeautifyrc @@ -41,4 +41,6 @@ indent_with_tabs: 0 indent_size: 1 ruby: + indent_size: 4 + erb: indent_size: 4 \ No newline at end of file diff --git a/examples/nested-jsbeautifyrc/html-erb/expected/test.erb b/examples/nested-jsbeautifyrc/html-erb/expected/test.erb new file mode 100644 index 0000000..dbff396 --- /dev/null +++ b/examples/nested-jsbeautifyrc/html-erb/expected/test.erb @@ -0,0 +1,18 @@ + + + + + Shopping List for + <%= @date.strftime('%A, %d %B %Y') %> + + +

Shopping List for + <%= @date.strftime('%A, %d %B %Y') %>

+

You need to buy:

+ + + \ No newline at end of file diff --git a/examples/simple-jsbeautifyrc/html-erb/original/test.erb b/examples/nested-jsbeautifyrc/html-erb/original/test.erb similarity index 100% rename from examples/simple-jsbeautifyrc/html-erb/original/test.erb rename to examples/nested-jsbeautifyrc/html-erb/original/test.erb diff --git a/examples/simple-jsbeautifyrc/html-erb/expected/test.erb b/examples/simple-jsbeautifyrc/html-erb/expected/test.erb deleted file mode 100644 index 0a45254..0000000 --- a/examples/simple-jsbeautifyrc/html-erb/expected/test.erb +++ /dev/null @@ -1,17 +0,0 @@ - - - - - Shopping List for <%= @date.strftime('%A, %d %B %Y') %> - - -

Shopping List for <%= @date.strftime('%A, %d %B %Y') %>

-

You need to buy:

- - - diff --git a/src/beautifiers/htmlbeautifier.coffee b/src/beautifiers/htmlbeautifier.coffee index 0bfbfc7..3ccfa9a 100644 --- a/src/beautifiers/htmlbeautifier.coffee +++ b/src/beautifiers/htmlbeautifier.coffee @@ -8,11 +8,14 @@ Beautifier = require('./beautifier') module.exports = class HTMLBeautifier extends Beautifier name: "HTML Beautifier" options: { - ERB: true + ERB: + indent_size: true } beautify: (text, language, options) -> + console.log('erb', options) @run("htmlbeautifier", [ + "--tab-stops", options.indent_size tempFile = @tempFile("temp", text) ]) .then(=> diff --git a/src/beautifiers/index.coffee b/src/beautifiers/index.coffee index 22743ca..e5a3fab 100644 --- a/src/beautifiers/index.coffee +++ b/src/beautifiers/index.coffee @@ -305,8 +305,8 @@ module.exports = class Beautifiers extends EventEmitter getOptionsForLanguage : (allOptions, language) -> # Options for Language - options = @getOptions([language.namespace]\ - .concat(language.fallback or []), allOptions) or {} + selections = (language.fallback or []).concat([language.namespace]) + options = @getOptions(selections, allOptions) or {} beautify : (text, allOptions, grammar, filePath, {onSave} = {}) -> return Promise.all(allOptions) @@ -364,7 +364,7 @@ module.exports = class Beautifiers extends EventEmitter return resolve( null ) # Options for Language - options = @getOptions([language.namespace].concat(language.fallback or []), allOptions) or {} + options = @getOptionsForLanguage(allOptions, language) # Get Beautifier logger.verbose(grammar, language) @@ -767,7 +767,7 @@ module.exports = class Beautifiers extends EventEmitter _ ?= require("lodash") extend ?= require("extend") - logger.verbose(selections, allOptions) + logger.verbose('getOptions selections', selections, allOptions) # logger.verbose(selection, allOptions); # Reduce all options into correctly merged options. diff --git a/src/languages/erb.coffee b/src/languages/erb.coffee index 081dd07..925de50 100644 --- a/src/languages/erb.coffee +++ b/src/languages/erb.coffee @@ -15,7 +15,11 @@ module.exports = { ### Supported extensions ### - extensions: [] + extensions: [ + 'erb' + ] + + defaultBeautifier: "Pretty Diff" options: [] diff --git a/src/logger.coffee b/src/logger.coffee index 8b86369..26f868e 100644 --- a/src/logger.coffee +++ b/src/logger.coffee @@ -47,13 +47,16 @@ module.exports = do -> ] }) wlogger.on('logging', (transport, level, msg, meta)-> - loggerLevel = atom?.config.get('atom-beautify._loggerLevel') ? "warn" + loggerLevel = atom?.config.get(\ + 'atom-beautify._loggerLevel') ? "warn" # console.log('logging', loggerLevel, arguments) loggerLevelNum = levels[loggerLevel] levelNum = levels[level] if loggerLevelNum <= levelNum path = require('path') - label = path.basename(transport.label) + label = "#{path.dirname(transport.label)\ + .split(path.sep).reverse()[0]}\ + #{path.sep}#{path.basename(transport.label)}" console.log("#{label} [#{level}]: #{msg}", meta) ) # Export logger methods