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

Method _getBlockName

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

Source from the content-addressed store, hash-verified

284 }
285
286 private _getBlockName(): string {
287 // This allows us to capture up something like `@else if`, but not `@ if`.
288 let spacesInNameAllowed = false;
289 const nameCursor = this._cursor.clone();
290
291 this._attemptCharCodeUntilFn((code) => {
292 if (chars.isWhitespace(code)) {
293 return !spacesInNameAllowed;
294 }
295 if (isBlockNameChar(code)) {
296 spacesInNameAllowed = true;
297 return false;
298 }
299 return true;
300 });
301
302 let result = this._cursor.getChars(nameCursor).trim();
303
304 // Normalize whitespaces.
305 if (ELSE_IF_PATTERN.test(result)) {
306 result = 'else if';
307 } else if (DEFAULT_NEVER_PATTERN.test(result)) {
308 result = 'default never';
309 }
310
311 return result;
312 }
313
314 private _consumeBlockStart(start: CharacterCursor) {
315 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