|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright Google Inc. All Rights Reserved. |
| 4 | + * |
| 5 | + * Use of this source code is governed by an MIT-style license that can be |
| 6 | + * found in the LICENSE file at https://angular.io/license |
| 7 | + */ |
| 8 | + |
| 9 | +import {GrammarDefinition} from './types'; |
| 10 | + |
| 11 | +export const TemplateTag: GrammarDefinition = { |
| 12 | + scopeName: 'template.tag.ng', |
| 13 | + injectionSelector: 'L:text.html#meta.tag -comment', |
| 14 | + patterns: [ |
| 15 | + {include: '#propertyBinding'}, |
| 16 | + {include: '#eventBinding'}, |
| 17 | + {include: '#twoWayBinding'}, |
| 18 | + {include: '#templateBinding'}, |
| 19 | + ], |
| 20 | + repository: { |
| 21 | + |
| 22 | + propertyBinding: { |
| 23 | + begin: /(\[\s*@?[-_a-zA-Z0-9.$]*%?\s*])(=)(["'])/, |
| 24 | + beginCaptures: { |
| 25 | + 1: { |
| 26 | + name: 'entity.other.attribute-name.html entity.other.ng-binding-name.property.html', |
| 27 | + patterns: [ |
| 28 | + {include: '#bindingKey'}, |
| 29 | + ], |
| 30 | + }, |
| 31 | + 2: {name: 'punctuation.separator.key-value.html'}, |
| 32 | + 3: {name: 'string.quoted.html punctuation.definition.string.begin.html'}, |
| 33 | + }, |
| 34 | + end: /\3/, |
| 35 | + endCaptures: { |
| 36 | + 0: {name: 'string.quoted.html punctuation.definition.string.end.html'}, |
| 37 | + }, |
| 38 | + name: 'meta.ng-binding.property.html', |
| 39 | + contentName: 'expression.ng', |
| 40 | + patterns: [ |
| 41 | + {include: 'expression.ng'}, |
| 42 | + ], |
| 43 | + }, |
| 44 | + |
| 45 | + eventBinding: { |
| 46 | + begin: /(\(\s*@?[-_a-zA-Z0-9.$]*\s*\))(=)(["'])/, |
| 47 | + beginCaptures: { |
| 48 | + 1: { |
| 49 | + name: 'entity.other.attribute-name.html entity.other.ng-binding-name.event.html', |
| 50 | + patterns: [ |
| 51 | + {include: '#bindingKey'}, |
| 52 | + ], |
| 53 | + }, |
| 54 | + 2: {name: 'punctuation.separator.key-value.html'}, |
| 55 | + 3: {name: 'string.quoted.html punctuation.definition.string.begin.html'}, |
| 56 | + }, |
| 57 | + end: /\3/, |
| 58 | + endCaptures: { |
| 59 | + 0: {name: 'string.quoted.html punctuation.definition.string.end.html'}, |
| 60 | + }, |
| 61 | + name: 'meta.ng-binding.event.html', |
| 62 | + contentName: 'expression.ng', |
| 63 | + patterns: [ |
| 64 | + {include: 'expression.ng'}, |
| 65 | + ], |
| 66 | + }, |
| 67 | + |
| 68 | + twoWayBinding: { |
| 69 | + begin: /(\[\s*\(\s*@?[-_a-zA-Z0-9.$]*\s*\)\s*\])(=)(["'])/, |
| 70 | + beginCaptures: { |
| 71 | + 1: { |
| 72 | + name: 'entity.other.attribute-name.html entity.other.ng-binding-name.two-way.html', |
| 73 | + patterns: [ |
| 74 | + {include: '#bindingKey'}, |
| 75 | + ], |
| 76 | + }, |
| 77 | + 2: {name: 'punctuation.separator.key-value.html'}, |
| 78 | + 3: {name: 'string.quoted.html punctuation.definition.string.begin.html'}, |
| 79 | + }, |
| 80 | + end: /\3/, |
| 81 | + endCaptures: { |
| 82 | + 0: {name: 'string.quoted.html punctuation.definition.string.end.html'}, |
| 83 | + }, |
| 84 | + name: 'meta.ng-binding.two-way.html', |
| 85 | + contentName: 'expression.ng', |
| 86 | + patterns: [ |
| 87 | + {include: 'expression.ng'}, |
| 88 | + ], |
| 89 | + }, |
| 90 | + |
| 91 | + templateBinding: { |
| 92 | + begin: /(\*[-_a-zA-Z0-9.$]*)(=)(["'])/, |
| 93 | + beginCaptures: { |
| 94 | + 1: { |
| 95 | + name: 'entity.other.attribute-name.html entity.other.ng-binding-name.template.html', |
| 96 | + patterns: [ |
| 97 | + {include: '#bindingKey'}, |
| 98 | + ], |
| 99 | + }, |
| 100 | + 2: {name: 'punctuation.separator.key-value.html'}, |
| 101 | + 3: {name: 'string.quoted.html punctuation.definition.string.begin.html'}, |
| 102 | + }, |
| 103 | + end: /\3/, |
| 104 | + endCaptures: { |
| 105 | + 0: {name: 'string.quoted.html punctuation.definition.string.end.html'}, |
| 106 | + }, |
| 107 | + name: 'meta.ng-binding.template.html', |
| 108 | + contentName: 'expression.ng', |
| 109 | + patterns: [ |
| 110 | + {include: 'expression.ng'}, |
| 111 | + ], |
| 112 | + }, |
| 113 | + |
| 114 | + bindingKey: { |
| 115 | + patterns: [ |
| 116 | + { |
| 117 | + match: /([\[\(]{1,2}|\*)(?:\s*)(@?[-_a-zA-Z0-9.$]*%?)(?:\s*)([\]\)]{1,2})?/, |
| 118 | + captures: { |
| 119 | + 1: {name: 'punctuation.definition.ng-binding-name.begin.html'}, |
| 120 | + 2: { |
| 121 | + name: 'entity.other.ng-binding-name.$2.html', |
| 122 | + patterns: [ |
| 123 | + { |
| 124 | + match: /\./, |
| 125 | + name: 'punctuation.accessor.html', |
| 126 | + }, |
| 127 | + ], |
| 128 | + }, |
| 129 | + 3: {name: 'punctuation.definition.ng-binding-name.end.html'}, |
| 130 | + }, |
| 131 | + }, |
| 132 | + ], |
| 133 | + }, |
| 134 | + }, |
| 135 | +}; |
0 commit comments