|
| 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 template: GrammarDefinition = { |
| 12 | + scopeName: 'template.ng', |
| 13 | + injectionSelector: 'L:text.html -comment', |
| 14 | + patterns: [ |
| 15 | + {include: '#interpolation'}, |
| 16 | + {include: '#propertyBinding'}, |
| 17 | + {include: '#eventBinding'}, |
| 18 | + {include: '#twoWayBinding'}, |
| 19 | + {include: '#templateBinding'}, |
| 20 | + ], |
| 21 | + repository: { |
| 22 | + |
| 23 | + interpolation: { |
| 24 | + begin: /{{/, |
| 25 | + beginCaptures: { |
| 26 | + 0: {name: 'punctuation.definition.block.ts'}, |
| 27 | + }, |
| 28 | + end: /}}/, |
| 29 | + endCaptures: { |
| 30 | + 0: {name: 'punctuation.definition.block.ts'}, |
| 31 | + }, |
| 32 | + contentName: 'source.js', |
| 33 | + patterns: [ |
| 34 | + {include: 'source.js'}, |
| 35 | + ], |
| 36 | + }, |
| 37 | + |
| 38 | + propertyBinding: { |
| 39 | + begin: /(\[\s*@?[-_a-zA-Z0-9.$]*\s*])(=)(["'])/, |
| 40 | + beginCaptures: { |
| 41 | + 1: { |
| 42 | + name: 'entity.other.attribute-name.html entity.other.ng-binding-name.property.html', |
| 43 | + patterns: [ |
| 44 | + {include: '#bindingKey'}, |
| 45 | + ], |
| 46 | + }, |
| 47 | + 2: {name: 'punctuation.separator.key-value.html'}, |
| 48 | + 3: {name: 'string.quoted.html punctuation.definition.string.begin.html'}, |
| 49 | + }, |
| 50 | + end: /\3/, |
| 51 | + endCaptures: { |
| 52 | + 0: {name: 'string.quoted.html punctuation.definition.string.end.html'}, |
| 53 | + }, |
| 54 | + name: 'meta.ng-binding.property.html', |
| 55 | + contentName: 'source.js', |
| 56 | + patterns: [ |
| 57 | + {include: 'source.js'}, |
| 58 | + ], |
| 59 | + }, |
| 60 | + |
| 61 | + eventBinding: { |
| 62 | + begin: /(\(\s*@?[-_a-zA-Z0-9.$]*\s*\))(=)(["'])/, |
| 63 | + beginCaptures: { |
| 64 | + 1: { |
| 65 | + name: 'entity.other.attribute-name.html entity.other.ng-binding-name.event.html', |
| 66 | + patterns: [ |
| 67 | + {include: '#bindingKey'}, |
| 68 | + ], |
| 69 | + }, |
| 70 | + 2: {name: 'punctuation.separator.key-value.html'}, |
| 71 | + 3: {name: 'string.quoted.html punctuation.definition.string.begin.html'}, |
| 72 | + }, |
| 73 | + end: /\3/, |
| 74 | + endCaptures: { |
| 75 | + 0: {name: 'string.quoted.html punctuation.definition.string.end.html'}, |
| 76 | + }, |
| 77 | + name: 'meta.ng-binding.event.html', |
| 78 | + contentName: 'source.js', |
| 79 | + patterns: [ |
| 80 | + {include: 'source.js'}, |
| 81 | + ], |
| 82 | + }, |
| 83 | + |
| 84 | + twoWayBinding: { |
| 85 | + begin: /(\[\s*\(\s*@?[-_a-zA-Z0-9.$]*\s*\)\s*\])(=)(["'])/, |
| 86 | + beginCaptures: { |
| 87 | + 1: { |
| 88 | + name: 'entity.other.attribute-name.html entity.other.ng-binding-name.two-way.html', |
| 89 | + patterns: [ |
| 90 | + {include: '#bindingKey'}, |
| 91 | + ], |
| 92 | + }, |
| 93 | + 2: {name: 'punctuation.separator.key-value.html'}, |
| 94 | + 3: {name: 'string.quoted.html punctuation.definition.string.begin.html'}, |
| 95 | + }, |
| 96 | + end: /\3/, |
| 97 | + endCaptures: { |
| 98 | + 0: {name: 'string.quoted.html punctuation.definition.string.end.html'}, |
| 99 | + }, |
| 100 | + name: 'meta.ng-binding.two-way.html', |
| 101 | + contentName: 'source.js', |
| 102 | + patterns: [ |
| 103 | + {include: 'source.js'}, |
| 104 | + ], |
| 105 | + }, |
| 106 | + |
| 107 | + templateBinding: { |
| 108 | + begin: /(\*[-_a-zA-Z0-9.$]*)(=)(["'])/, |
| 109 | + beginCaptures: { |
| 110 | + 1: { |
| 111 | + name: 'entity.other.attribute-name.html entity.other.ng-binding-name.template.html', |
| 112 | + patterns: [ |
| 113 | + {include: '#bindingKey'}, |
| 114 | + ], |
| 115 | + }, |
| 116 | + 2: {name: 'punctuation.separator.key-value.html'}, |
| 117 | + 3: {name: 'string.quoted.html punctuation.definition.string.begin.html'}, |
| 118 | + }, |
| 119 | + end: /\3/, |
| 120 | + endCaptures: { |
| 121 | + 0: {name: 'string.quoted.html punctuation.definition.string.end.html'}, |
| 122 | + }, |
| 123 | + name: 'meta.ng-binding.template.html', |
| 124 | + contentName: 'source.js', |
| 125 | + patterns: [ |
| 126 | + {include: 'source.js'}, |
| 127 | + ], |
| 128 | + }, |
| 129 | + |
| 130 | + bindingKey: { |
| 131 | + patterns: [ |
| 132 | + { |
| 133 | + match: /([\[\(]{1,2})(?:\s*)(@?[-_a-zA-Z0-9.$]*)(?:\s*)([\]\)]{1,2})/, |
| 134 | + captures: { |
| 135 | + 1: {name: 'punctuation.definition.ng-binding-name.begin.html'}, |
| 136 | + 2: { |
| 137 | + patterns: [ |
| 138 | + { |
| 139 | + match: /\./, |
| 140 | + name: 'punctuation.accessor.html', |
| 141 | + }, |
| 142 | + ], |
| 143 | + }, |
| 144 | + 3: {name: 'punctuation.definition.ng-binding-name.end.html'}, |
| 145 | + }, |
| 146 | + }, |
| 147 | + ], |
| 148 | + }, |
| 149 | + }, |
| 150 | +}; |
0 commit comments