MCPcopy Index your code
hub / github.com/angular/angular / parse

Function parse

packages/language-service/test/legacy/template_target_spec.ts:64–85  ·  view source on GitHub ↗
(template: string, enableSelectorless = false)

Source from the content-addressed store, hash-verified

62}
63
64function parse(template: string, enableSelectorless = false): ParseResult {
65 const position = template.indexOf('¦');
66 if (position < 0) {
67 throw new Error(`Template "${template}" does not contain the cursor`);
68 }
69 template = template.replace('¦', '');
70 const templateUrl = '/foo';
71 return {
72 ...parseTemplate(template, templateUrl, {
73 // Set `leadingTriviaChars` and `preserveWhitespaces` such that whitespace is not stripped
74 // and fully accounted for in source spans. Without these flags the source spans can be
75 // inaccurate.
76 // Note: template parse options should be aligned with the `diagNodes` in
77 // `ComponentDecoratorHandler._parseTemplate`.
78 leadingTriviaChars: [],
79 preserveWhitespaces: true,
80 alwaysAttemptHtmlToR3AstConversion: true,
81 enableSelectorless,
82 }),
83 position,
84 };
85}
86
87describe('getTargetAtPosition for template AST', () => {
88 it('should locate incomplete tag', () => {

Callers 1

Calls 3

parseTemplateFunction · 0.90
indexOfMethod · 0.80
replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…