Skip to content

Jinja2TemplateParser

reference
1 min readUpdated

Kind: Class

Source: atloria-monorepo/libs/parser-core/src/parsers/backend/jinja2-template.parser.ts

Jinja2 Template Parser

Extracts entities and relationships from Jinja2 template files.

Implements: IParser

Methods

MethodSignatureReturns
initializeinitialize(config: { rootDir: string })Promise<void>
canParsecanParse(filePath: string)boolean
parseFileparseFile(filePath: string, content: string)Promise<ParseResult>
parseFilesparseFiles(files: ParseFileInput[])Promise<ParseResult[]>
destroydestroy()Promise<void>

Properties

PropertyType
nameany
versionany
supportedPatternsany

Where it refuses work

  • Jinja2TemplateParser stops the work with an early return when /from\s+flask\s+import|import\s+flask/i.test(content).
  • Jinja2TemplateParser stops the work with an early return when /flask|jinja2/i.test(content).
  • Jinja2TemplateParser stops the work with an early return when filePath.endsWith('.jinja2') || filePath.endsWith('.j2').
  • Jinja2TemplateParser stops the work with an early return when !this.projectHasJinja2.
  • Jinja2TemplateParser stops the work with an early return when templatesIndex !== -1 && templatesIndex < parts.length - 1.
  • Jinja2TemplateParser stops the work with an early return when match.

When something fails

  • Jinja2TemplateParser handles failure in 3 places: it discards it silently in 2, and turns it into a return value in 1.

Was this page helpful?

Download as PDF