This commit is contained in:
Tutur33
2023-11-24 22:35:41 +01:00
parent 3c0b507a93
commit 7644b2a0f7
45165 changed files with 4803356 additions and 3 deletions
+66
View File
@@ -0,0 +1,66 @@
import { TagToken, LexerTagDefinitionContract, MustacheToken } from 'edge-lexer';
import { Parser } from '../Parser';
import { EdgeBuffer } from '../EdgeBuffer';
/**
* The parser needs the `compile` method on every tag
*/
export interface ParserTagDefinitionContract extends LexerTagDefinitionContract {
compile(parser: Parser, buffer: EdgeBuffer, token: TagToken): void;
}
/**
* Loc node from Acorn
*/
export type AcornLoc = {
start: {
line: number;
column: number;
};
end: {
line: number;
column: number;
};
};
export type TagTransformer = (tag: TagToken) => void;
export type MustacheTransformer = (tag: MustacheToken) => void;
export type ClaimTagFn = (name: string) => LexerTagDefinitionContract | null;
export type OnLineFn = (line: string) => string;
/**
* Parser options
*/
export type ParserOptions = {
/**
* Is parsing in async mode
*/
async?: boolean;
/**
* Modify the line before it is being processed by the lexer
*/
onLine?: OnLineFn;
/**
* Modify the tag before it is being processed by the parser
*/
onTag?: TagTransformer;
/**
* Modify the mustache block before it is being processed by the parser
*/
onMustache?: MustacheTransformer;
/**
* Claim un-registered tags
*/
claimTag?: ClaimTagFn;
/**
* Nested or flat path to the escape method for escaping values.
*/
escapeCallPath: string | [string, string];
/**
* Name of the property to be used for accessing the values from
* the template. Leave it to an empty string, if properties
* are available directly (meaning without a subpath).
*/
statePropertyName: string;
/**
* An array of local variables to be accessible directly. Define these
* so that the parser doesn't access them from the state property.
*/
localVariables?: string[];
};
+10
View File
@@ -0,0 +1,10 @@
"use strict";
/*
* edge-parser
*
* (c) Harminder Virk <virk@adonisjs.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
Object.defineProperty(exports, "__esModule", { value: true });