Skip to content

Commit

Permalink
Turn off new angular templating by default in html
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwiseman committed Feb 16, 2024
1 parent b4775c3 commit 96340d5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
7 changes: 4 additions & 3 deletions js/src/cli.js
Expand Up @@ -199,7 +199,7 @@ var path = require('path'),
// no shorthand for "config"
// no shorthand for "editorconfig"
// no shorthand for "indent_empty_lines"
// not shorthad for "templating"
// no shorthad for "templating"
});

function verifyExists(fullPath) {
Expand Down Expand Up @@ -370,7 +370,8 @@ function usage(err) {
' [first newline in file, otherwise "\\n]',
' -n, --end-with-newline End output with newline',
' --indent-empty-lines Keep indentation on empty lines',
' --templating List of templating languages (auto,none,django,erb,handlebars,php,smarty,angular) ["auto"] auto = none in JavaScript, all in html',
' --templating List of templating languages (auto,none,angular,django,erb,handlebars,php,smarty)',
' ["auto", auto = none in JavaScript, auto = all except angular in html (and inline javascript/css)]',
' --editorconfig Use EditorConfig to set up the options'
];

Expand Down Expand Up @@ -409,7 +410,7 @@ function usage(err) {
msg.push(' -U, --unformatted List of tags (defaults to inline) that should not be reformatted');
msg.push(' -T, --content_unformatted List of tags (defaults to pre) whose content should not be reformatted');
msg.push(' -E, --extra_liners List of tags (defaults to [head,body,/html] that should have an extra newline');
msg.push(' --unformatted_content_delimiter Keep text content together between this string [""]');
msg.push(' --unformatted_content_delimiter Keep text content together between this string [""]');
break;
case "css":
msg.push(' -b, --brace-style [collapse|expand] ["collapse"]');
Expand Down
4 changes: 2 additions & 2 deletions js/src/core/options.js
Expand Up @@ -68,9 +68,9 @@ function Options(options, merge_child_field) {
this.indent_empty_lines = this._get_boolean('indent_empty_lines');

// valid templating languages ['django', 'erb', 'handlebars', 'php', 'smarty', 'angular']
// For now, 'auto' = all off for javascript, all on for html (and inline javascript).
// For now, 'auto' = all off for javascript, all except angular on for html (and inline javascript/css).
// other values ignored
this.templating = this._get_selection_list('templating', ['auto', 'none', 'django', 'erb', 'handlebars', 'php', 'smarty', 'angular'], ['auto']);
this.templating = this._get_selection_list('templating', ['auto', 'none', 'angular', 'django', 'erb', 'handlebars', 'php', 'smarty'], ['auto']);
}

Options.prototype._get_array = function(name, default_value) {
Expand Down
2 changes: 1 addition & 1 deletion js/src/html/options.js
Expand Up @@ -33,7 +33,7 @@ var BaseOptions = require('../core/options').Options;
function Options(options) {
BaseOptions.call(this, options, 'html');
if (this.templating.length === 1 && this.templating[0] === 'auto') {
this.templating = ['django', 'erb', 'handlebars', 'php', 'angular'];
this.templating = ['django', 'erb', 'handlebars', 'php'];
}

this.indent_inner_html = this._get_boolean('indent_inner_html');
Expand Down
4 changes: 2 additions & 2 deletions python/jsbeautifier/core/options.py
Expand Up @@ -77,11 +77,11 @@ def __init__(self, options=None, merge_child_field=None):
self.indent_empty_lines = self._get_boolean("indent_empty_lines")

# valid templating languages ['django', 'erb', 'handlebars', 'php', 'smarty', 'angular']
# For now, 'auto' = all off for javascript, all on for html (and inline javascript).
# For now, 'auto' = all off for javascript, all except angular on for html (and inline javascript/css).
# other values ignored
self.templating = self._get_selection_list(
"templating",
["auto", "none", "django", "erb", "handlebars", "php", "smarty", "angular"],
["auto", "none", "angular", "django", "erb", "handlebars", "php", "smarty"],
["auto"],
)

Expand Down
10 changes: 4 additions & 6 deletions python/jsbeautifier/tests/core/test_options.py
Expand Up @@ -102,15 +102,13 @@ def test__is_valid_selection(self):

def test__get_selection_list(self):
# should raise error with empty selection
with self.assertRaisesRegexp(
ValueError, "Selection list cannot" + " be empty."
):
with self.assertRaisesRegex(ValueError, "Selection list cannot" + " be empty."):
Options()._get_selection_list("a", [])
# should raise error with invalid default
with self.assertRaisesRegexp(ValueError, "Invalid Default Value!"):
with self.assertRaisesRegex(ValueError, "Invalid Default Value!"):
Options()._get_selection_list("a", ["a", "b"], ["c"])
# should raise error with invalid option
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError, "^Invalid Option Value:" + " The option"
):
Options({"a": ["c", "d"]})._get_selection_list("a", ["a", "b"], ["a", "b"])
Expand All @@ -120,7 +118,7 @@ def test__get_selection_list(self):

def test__get_selection(self):
# should raise error with multiple selection
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError, "^Invalid Option" + " Value: The option"
):
Options({"a": ["a", "b"]})._get_selection("a", ["a", "b"], ["a"])
Expand Down

0 comments on commit 96340d5

Please sign in to comment.