UNPKG

boats

Version:

Beautiful Open / Async Template System - Write less yaml with BOATS and Nunjucks.

101 lines (100 loc) 3.78 kB
import nunjucks from 'nunjucks'; import { BoatsRC } from './interfaces/BoatsRc'; declare class Template { isAsyncApiFile: boolean; originalIndentation: number; mixinVarNamePrefix: string; helpFunctionPaths: string[]; variables: any[]; boatsrc: any; inputFile: string; stripValue: string; currentFilePointer: string; mixinObject: any[]; mixinNumber: number; indentObject: any[]; indentNumber: number; /** * Parses all files in a folder against the nunjuck tpl engine and outputs in a mirrored path the in provided outputDirectory * @param inputFile The input directory to start parsing from * @param output The directory to output/mirror to * @param originalIndent The original indent (currently hard coded to 2) * @param stripValue The strip value for the uniqueOpIp * @param variables The variables for the tpl engine * @param helpFunctionPaths Array of fully qualified local file paths to nunjucks helper functions * @param boatsrc * @param oneFileOutput When passed will output the tpl compiled files into a tmp folder, TMP_COMPILED_DIR_NAME */ directoryParse(inputFile: string, output: string, originalIndent: number, stripValue: string, variables: any[], helpFunctionPaths: string[], boatsrc: BoatsRC, oneFileOutput: boolean): string; setDefaultStripValue(stripValue?: string, inputString?: string): string; /** * Cleans the input string to ensure a match with the walker package when mirroring * @param relativeFilePath */ cleanInputString(relativeFilePath: string): string; /** * Calculates the output file based on the input file, used for mirroring the input src dir. * Any .njk ext will automatically be removed. */ calculateOutputFile(input: { inputFile: string; currentFile: string; output: string; oneFileOutput: boolean; }): string; /** * Strips out the njk ext from a given string * @param input * @return string */ stripNjkExtension(input: string): string; /** * After render use only, takes a rendered njk file and replaces the .yml.njk with .njk * @param multiLineBlock */ stripNjkExtensionFrom$Refs(multiLineBlock: string): string; /** * Loads and renders a tpl file * @param inputString The string to parse * @param fileLocation The file location the string for the current */ renderFile(inputString: string, fileLocation: string): string; /** * * @param str The string to look for mixins * @param originalIndentation The original indentation setting, defaults to 2 * @returns {Array} */ setMixinPositions(str: string, originalIndentation?: number): any[]; /** * * @param str The string to look for helpers that need indentations * @param originalIndentation The original indentation setting, defaults to 2 * @returns {Array} */ setIndentPositions(str: string, originalIndentation?: number): any[]; /** * Sets up the tpl engine for the current file being rendered */ nunjucksSetup(): void; /** * Default nunjucks env configuration * * @return {nunjucks.Environment} */ setupDefaultNunjucksEnv(): nunjucks.Environment; /** * Loads js and ts helpers from files / folders, overriding existing if they * exist. * * @param {nunjucks.Environment} env The environment */ loadHelpers(env: nunjucks.Environment): void; /** * Returns an alpha numeric underscore helper function name * @param filePath */ getHelperFunctionNameFromPath(filePath: string): string; } declare const _default: Template; export default _default;