Skip to content

Commit

Permalink
Add setting to disable twig - closes #30 (#32)
Browse files Browse the repository at this point in the history
* allow disabling of twig tags

* wip
  • Loading branch information
austenc authored Feb 20, 2024
1 parent da21fd5 commit 36f620e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 57 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
64 changes: 9 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
6 changes: 4 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ class Spacer {
}

public replace(editor: TextEditor, tagType: number, ranges: Array<Range>) {
const twigEnabled = workspace.getConfiguration('bladeSpacer').enableTwig

if (tagType === this.TAG_DOUBLE) {
return editor.insertSnippet(
new SnippetString('{{ ${1:${TM_SELECTED_TEXT/[{}]//g}} }}$0'),
Expand All @@ -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
Expand Down

0 comments on commit 36f620e

Please sign in to comment.