@rxap/schematics-xml-parser
Version:
This package provides utilities for parsing XML templates within Angular Schematics. It includes functionality to locate templates in a file system, parse them using a specified DOMParser, and register custom elements for parsing. The package also offers
43 lines (42 loc) • 1.67 kB
TypeScript
import { DirEntry, Tree } from '@angular-devkit/schematics';
import { Constructor } from '@rxap/schematics-utilities';
import { ParsedElement } from '@rxap/xml-parser';
export declare function FindTemplate(template: string, host: Tree, basePath: string | undefined, baseDirEntry?: DirEntry): string | null;
/**
* Parse the template and returns the ParsedElement object
*
* The template parameter can be an xml document or a path to a xml document.
*
* The xml document must be in the templates directory.
*
* It is possible to provide a relative template path.
* If the basePath property is not set to undefined then a search in the sub directory is
* started.
*
* Examples
*
* Example 1
*
* template = 'views/tables/product.xml'
* basePath = undefined
*
* The following path are checked in order:
* - templates/views/tables/product.xml
* - templates/shared/views/tables/product.xml
*
* Example 2
*
* template = 'views/tables/product.xml'
* basePath = 'feature/product'
*
* The following path are checked in order:
* - templates/feature/product/views/tables/product.xml
* - templates/shared/views/tables/product.xml
*
* @param DOMParser
* @param host a schematic Tree instance
* @param template the path to the template xml document or a xml document
* @param basePath the basePath for the search
* @param elements a collection of ParsedElement class constructors that should be include in the xml parsing
*/
export declare function ParseTemplate<T extends ParsedElement>(DOMParser: typeof window.DOMParser, host: Tree, template: string, basePath: string | string[] | undefined, ...elements: Array<Constructor<ParsedElement>>): T;