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

Function getTcbTemplateSource

packages/compiler-cli/preprocessor/src/tcb.ts:124–153  ·  view source on GitHub ↗
(
  component: nga.ComponentMetadata | undefined,
)

Source from the content-addressed store, hash-verified

122export const TCB_TEMPLATE_SOURCES_COMMENT_PREFIX = 'ngp-tcb-template-sources:';
123
124function getTcbTemplateSource(
125 component: nga.ComponentMetadata | undefined,
126): TcbTemplateSource | null {
127 if (!component) {
128 return null;
129 }
130 // Same classification as the processor's `templateDiagnosticLocation`.
131 if (component.templateUrl != null) {
132 return {
133 ...(component.className ? {className: component.className} : {}),
134 templateFile: component.templateUrl.resolvedPath,
135 ...(component.templateUrlSpan
136 ? {
137 templateUrlExpression: {
138 start: component.templateUrlSpan.start,
139 end: component.templateUrlSpan.end,
140 },
141 }
142 : {}),
143 };
144 }
145 const expressionSpan = component.templateSpan;
146 if (component.templateContentSpan != null || expressionSpan == null) {
147 return null;
148 }
149 return {
150 ...(component.className ? {className: component.className} : {}),
151 templateExpression: {start: expressionSpan.start, end: expressionSpan.end},
152 };
153}
154
155function serializeTcbTemplateSources(templateSources: Record<string, TcbTemplateSource>): string {
156 if (Object.keys(templateSources).length === 0) {

Callers 1

generateTcbCodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected