-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Adds a basic XML owl template - Make use of `$TM_FILENAME_BASE` and `$RELATIVE_FILEPATH` and attempt to predict the component and template names. See: https://code.visualstudio.com/docs/editor/userdefinedsnippets#_variables
- Loading branch information
1 parent
9b18b57
commit dd29247
Showing
1 changed file
with
29 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,43 @@ | ||
{ | ||
"Basic owl component": { | ||
"Basic OWL Component": { | ||
"prefix": "owlcomponent", | ||
"scope": "javascript,typescript", | ||
"body": [ | ||
"export class ${1:component-name} extends Component {", | ||
" static template = \"${2:template-name}\";", | ||
"import { Component } from \"@odoo/owl\";", | ||
"", | ||
"class ${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}} extends ${2:Component} {", | ||
"", | ||
" static template = \"${3:${RELATIVE_FILEPATH/(.*[\\|\\/])??([a-zA-Z_]+)([\\|\\/]static[\\|\\/].*)/${2}/g}}.${4:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}}\";", | ||
" static components = {};", | ||
" static props = {};", | ||
"", | ||
" setup() {", | ||
"", | ||
" ${5:super.setup();}", | ||
" }", | ||
"", | ||
" ${6:// Do Something}", | ||
"}", | ||
"" | ||
|
||
], | ||
"description": "The starting base for an owl component" | ||
}, | ||
|
||
"Basic OWL Template": { | ||
"prefix": "owltemplate", | ||
"scope": "xml", | ||
"body": [ | ||
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>", | ||
"", | ||
"<templates xml:space=\"preserve\">", | ||
"", | ||
" <t t-name=\"${2:${RELATIVE_FILEPATH/(.*[\\|\\/])??([a-zA-Z_]+)([\\|\\/]static[\\|\\/].*)/${2}/g}}.${3:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}}\">", | ||
" ${3:<h1>Hello World</h1>}", | ||
" </t>", | ||
"", | ||
"</templates>", | ||
"" | ||
], | ||
"description": "Generate a basic OWL template XML file" | ||
} | ||
} |