MCPcopy Create free account
hub / github.com/angular/angular / _getBlockName

Method _getBlockName

packages/compiler/src/ml_parser/lexer.ts:274–300  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

272 }
273
274 private _getBlockName(): string {
275 // This allows us to capture up something like `@else if`, but not `@ if`.
276 let spacesInNameAllowed = false;
277 const nameCursor = this._cursor.clone();
278
279 this._attemptCharCodeUntilFn((code) => {
280 if (chars.isWhitespace(code)) {
281 return !spacesInNameAllowed;
282 }
283 if (isBlockNameChar(code)) {
284 spacesInNameAllowed = true;
285 return false;
286 }
287 return true;
288 });
289
290 let result = this._cursor.getChars(nameCursor).trim();
291
292 // Normalize whitespaces.
293 if (ELSE_IF_PATTERN.test(result)) {
294 result = 'else if';
295 } else if (DEFAULT_NEVER_PATTERN.test(result)) {
296 result = 'default never';
297 }
298
299 return result;
300 }
301
302 private _consumeBlockStart(start: CharacterCursor) {
303 this._requireCharCode(chars.$AT);

Callers 1

_consumeBlockStartMethod · 0.95

Calls 5

isBlockNameCharFunction · 0.85
cloneMethod · 0.65
getCharsMethod · 0.65
testMethod · 0.45

Tested by

no test coverage detected