diff --git a/CHANGELOG.md b/CHANGELOG.md index 16d414d..8fb1c5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Change Log ### [Unreleased] +### 2.3.0 + +- Added new setting `bladeSpacer.enableTwig` to toggle support for Twig templates (`{% %}` and `{# #}`) - Fixed cursor placement when VsCodeVim is also installed ### 2.2.0 diff --git a/README.md b/README.md index 7d81945..84d8000 100644 --- a/README.md +++ b/README.md @@ -18,63 +18,17 @@ Supports the following tags: - Wrapping selected text with `{!! !!}`, `{{-- --}}`, `{% %}`, or `{# #}` tags doesn't work -## Release Notes - -### 2.2.0 - -- Fix npm install issues -- Fix console errors when translating selections -- Add support for Twig syntax `{# #}` and `{% %}` - - -### 2.1.3 - -- Fixed npm vulnerabilities -- Use async/await to fix interaction with some extensions - #17 - -### 2.1.2 - -- Fixed npm vulnerability - -### 2.1.1 - -- Fixed issues noted in [#14](https://github.com/austenc/vscode-blade-spacer/issues/14) - -### 2.1.0 +## Configuration -- Automatically enable `editor.autoClosingBrackets` for blade and html language types -- Fixed greedy regex for `{{ }}` and `{!! !!}` tag pairs - #11 +The extension can be configured by adding the following settings to your `settings.json` file: -### 2.0.2 +### Twig Templating -- Fixed bug causing issues with other extensions, thanks @KapitanOczywisty! +The extension includes support for Twig templates (`{% %}` and `{# #}`) out of the box, but can be disabled by adding the following setting to your `settings.json` file: +```json +"bladeSpacer.enableTwig": false, +``` -### 2.0.1 - -- Fixed bug with comment and unescaped tag types when making from existing `{{` - -### 2.0.0 - -- Dropped support for `{{{ }}}` tags -- Improved how extension activates, should be more performant -- Fixed https://github.com/austenc/vscode-blade-spacer/issues/3 -- Fixed https://github.com/austenc/vscode-blade-spacer/issues/4 - -### 1.0.2 - -- Fixed an issue that caused extraneous brackets when cursor at the beginning of a comment - #2 - -### 1.0.1 - -- Added workaround for braces not matching when a trailing quote or angle bracket exists - see Microsoft/vscode#35197 - -### 1.0.0 - -- Improved support for multi cursor and selection wrapping -- Fixed multi cursor undo problem -- Added support for triple brace syntax -- Added support for comment syntax - -### 0.1.0 +## Release Notes -- Initial version supporting `{{` and `{!!` tags. Buggy, but it's a start! +See the [changelog](CHANGELOG.md) for more information. diff --git a/package.json b/package.json index 6c17b95..ad89727 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,17 @@ "[blade]": { "editor.autoClosingBrackets": "always" } + }, + "configuration": { + "type": "object", + "title": "Laravel Blade Spacer", + "properties": { + "bladeSpacer.enableTwig": { + "type": "boolean", + "default": true, + "description": "Enable support for Twig templating tags (e.g. {% %} or {# #})" + } + } } }, "activationEvents": [ diff --git a/src/extension.ts b/src/extension.ts index a4ef3a9..775c393 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -141,6 +141,8 @@ class Spacer { } public replace(editor: TextEditor, tagType: number, ranges: Array) { + const twigEnabled = workspace.getConfiguration('bladeSpacer').enableTwig + if (tagType === this.TAG_DOUBLE) { return editor.insertSnippet( new SnippetString('{{ ${1:${TM_SELECTED_TEXT/[{}]//g}} }}$0'), @@ -156,12 +158,12 @@ class Spacer { new SnippetString('{{-- ${1:${TM_SELECTED_TEXT/(--)|[{} ]//g}} --}}$0'), ranges ) - } else if (tagType === this.TAG_TWIG_PER) { + } else if (twigEnabled && tagType === this.TAG_TWIG_PER) { return editor.insertSnippet( new SnippetString('{% $1 %}$0'), ranges ) - } else if (tagType === this.TAG_TWIG_HASH) { + } else if (twigEnabled && tagType === this.TAG_TWIG_HASH) { return editor.insertSnippet( new SnippetString('{# $1 #}$0'), ranges