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

Function parse

packages/language-service/test/legacy/template_target_spec.ts:62–82  ·  view source on GitHub ↗
(template: string)

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 3

parseTemplateFunction · 0.90
indexOfMethod · 0.80
replaceMethod · 0.45

Tested by

no test coverage detected