This commit is contained in:
harttle
2019-02-19 23:55:38 +08:00
parent cbebb00ef1
commit 29f53304bc
70 changed files with 3162 additions and 2565 deletions
+12
View File
@@ -0,0 +1,12 @@
declare const _default: {
'join': (v: any, arg: any) => any;
'last': (v: any) => any;
'first': (v: any) => any;
'map': (arr: any, arg: any) => any;
'reverse': (v: any) => any;
'sort': (v: any, arg: any) => any;
'size': (v: any) => any;
'slice': (v: any, begin: any, length: any) => any;
'uniq': (arr: any) => any;
};
export default _default;
+4
View File
@@ -0,0 +1,4 @@
declare const _default: {
'date': (v: any, arg: any) => any;
};
export default _default;
+8
View File
@@ -0,0 +1,8 @@
declare function escape(str: any): string;
declare const _default: {
'escape': typeof escape;
'escape_once': (str: any) => string;
'newline_to_br': (v: any) => any;
'strip_html': (v: any) => string;
};
export default _default;
+46
View File
@@ -0,0 +1,46 @@
declare const _default: {
'join': (v: any, arg: any) => any;
'last': (v: any) => any;
'first': (v: any) => any;
'map': (arr: any, arg: any) => any;
'reverse': (v: any) => any;
'sort': (v: any, arg: any) => any;
'size': (v: any) => any;
'slice': (v: any, begin: any, length: any) => any;
'uniq': (arr: any) => any;
'default': (v: any, arg: any) => any;
'date': (v: any, arg: any) => any;
'url_decode': (x: any) => any;
'url_encode': (x: any) => any;
'abs': (v: any) => number;
'ceil': (v: any) => number;
'divided_by': (v: any, arg: any) => number;
'floor': (v: any) => number;
'minus': (l: any, r: any) => any;
'modulo': (l: any, r: any) => any;
'round': (v: any, arg: any) => number;
'plus': (l: any, r: any) => any;
'times': (v: any, arg: any) => number;
'append': (v: any, arg: any) => any;
'prepend': (v: any, arg: any) => any;
'capitalize': (str: any) => string;
'concat': (v: any, arg: any) => any;
'lstrip': (v: any) => string;
'downcase': (v: any) => any;
'upcase': (str: any) => string;
'remove': (v: any, arg: any) => any;
'remove_first': (v: any, l: any) => any;
'replace': (v: any, pattern: any, replacement: any) => string;
'replace_first': (v: any, arg1: any, arg2: any) => string;
'rstrip': (str: any) => string;
'split': (v: any, arg: any) => string[];
'strip': (v: any) => string;
'strip_newlines': (v: any) => string;
'truncate': (v: any, l: any, o: any) => any;
'truncatewords': (v: any, l: any, o: any) => any;
'escape': (str: any) => string;
'escape_once': (str: any) => string;
'newline_to_br': (v: any) => any;
'strip_html': (v: any) => string;
};
export default _default;
+12
View File
@@ -0,0 +1,12 @@
declare const _default: {
'abs': (v: any) => number;
'ceil': (v: any) => number;
'divided_by': (v: any, arg: any) => number;
'floor': (v: any) => number;
'minus': (l: any, r: any) => any;
'modulo': (l: any, r: any) => any;
'round': (v: any, arg: any) => number;
'plus': (l: any, r: any) => any;
'times': (v: any, arg: any) => number;
};
export default _default;
+4
View File
@@ -0,0 +1,4 @@
declare const _default: {
'default': (v: any, arg: any) => any;
};
export default _default;
+20
View File
@@ -0,0 +1,20 @@
declare const _default: {
'append': (v: any, arg: any) => any;
'prepend': (v: any, arg: any) => any;
'capitalize': (str: any) => string;
'concat': (v: any, arg: any) => any;
'lstrip': (v: any) => string;
'downcase': (v: any) => any;
'upcase': (str: any) => string;
'remove': (v: any, arg: any) => any;
'remove_first': (v: any, l: any) => any;
'replace': (v: any, pattern: any, replacement: any) => string;
'replace_first': (v: any, arg1: any, arg2: any) => string;
'rstrip': (str: any) => string;
'split': (v: any, arg: any) => string[];
'strip': (v: any) => string;
'strip_newlines': (v: any) => string;
'truncate': (v: any, l: any, o: any) => any;
'truncatewords': (v: any, l: any, o: any) => any;
};
export default _default;
+5
View File
@@ -0,0 +1,5 @@
declare const _default: {
'url_decode': (x: any) => any;
'url_encode': (x: any) => any;
};
export default _default;
+5
View File
@@ -0,0 +1,5 @@
declare const _default: {
parse: (token: any) => void;
render: (scope: any) => Promise<string>;
};
export default _default;
+5
View File
@@ -0,0 +1,5 @@
declare const _default: {
parse: (token: any, remainTokens: any) => void;
render: (scope: any) => Promise<any>;
};
export default _default;
+4
View File
@@ -0,0 +1,4 @@
declare const _default: {
render: () => Promise<never>;
};
export default _default;
+8
View File
@@ -0,0 +1,8 @@
import TagToken from 'src/parser/tag-token';
import Token from 'src/parser/token';
import Scope from 'src/scope/scope';
declare const _default: {
parse: (tagToken: TagToken, remainTokens: Token[]) => void;
render: (scope: Scope) => Promise<void>;
};
export default _default;
+5
View File
@@ -0,0 +1,5 @@
declare const _default: {
parse: (tagToken: any, remainTokens: any) => void;
render: (scope: any) => any;
};
export default _default;
+4
View File
@@ -0,0 +1,4 @@
declare const _default: {
parse: (tagToken: any, remainTokens: any) => void;
};
export default _default;
+4
View File
@@ -0,0 +1,4 @@
declare const _default: {
render: () => Promise<never>;
};
export default _default;
+5
View File
@@ -0,0 +1,5 @@
declare const _default: {
parse: (tagToken: any) => void;
render: (scope: any) => any;
};
export default _default;
+7
View File
@@ -0,0 +1,7 @@
import TagToken from 'src/parser/tag-token';
import Scope from 'src/scope/scope';
declare const _default: {
parse: (token: TagToken) => void;
render: (scope: Scope) => number;
};
export default _default;
+7
View File
@@ -0,0 +1,7 @@
declare function parse(tagToken: any, remainTokens: any): void;
declare function render(scope: any, hash: any): Promise<any>;
declare const _default: {
parse: typeof parse;
render: typeof render;
};
export default _default;
+5
View File
@@ -0,0 +1,5 @@
declare const _default: {
parse: (tagToken: any, remainTokens: any) => void;
render: (scope: any) => any;
};
export default _default;
+5
View File
@@ -0,0 +1,5 @@
declare const _default: {
parse: (token: any) => void;
render: (scope: any, hash: any) => Promise<any>;
};
export default _default;
+5
View File
@@ -0,0 +1,5 @@
declare const _default: {
parse: (token: any) => void;
render: (scope: any) => any;
};
export default _default;
+5
View File
@@ -0,0 +1,5 @@
import ITagImplOptions from 'src/template/tag/itag-impl-options';
declare const tags: {
[key: string]: ITagImplOptions;
};
export default tags;
+5
View File
@@ -0,0 +1,5 @@
declare const _default: {
parse: (token: any, remainTokens: any) => void;
render: (scope: any, hash: any) => Promise<any>;
};
export default _default;
+5
View File
@@ -0,0 +1,5 @@
declare const _default: {
parse: (tagToken: any, remainTokens: any) => void;
render: () => any;
};
export default _default;
+5
View File
@@ -0,0 +1,5 @@
declare const _default: {
parse: (tagToken: any, remainTokens: any) => void;
render: (scope: any, hash: any) => Promise<string>;
};
export default _default;
+5
View File
@@ -0,0 +1,5 @@
declare const _default: {
parse: (tagToken: any, remainTokens: any) => void;
render: (scope: any) => any;
};
export default _default;
+3
View File
@@ -0,0 +1,3 @@
import IFS from './ifs';
declare const _default: IFS;
export default _default;
+5
View File
@@ -0,0 +1,5 @@
export default interface IFS {
exists: (filepath?: string) => Promise<boolean>;
readFile: (filepath: string) => Promise<string>;
resolve: (root: string, file: string, ext: string) => string;
}
+3
View File
@@ -0,0 +1,3 @@
import IFS from './ifs';
declare const fs: IFS;
export default fs;
+29
View File
@@ -0,0 +1,29 @@
export interface LiquidOptions {
/** `root` is a directory or an array of directories to resolve layouts and includes, as well as the filename passed in when calling `.renderFile()`. If an array, the files are looked up in the order they occur in the array. Defaults to `["."]` */
root?: string | string[];
/** `extname` is used to lookup the template file when filepath doesn't include an extension name. Eg: setting to `".html"` will allow including file by basename. Defaults to `""`. */
extname?: string;
/** `cache` indicates whether or not to cache resolved templates. Defaults to `false`. */
cache?: boolean;
/** `dynamicPartials`: if set, treat `<filepath>` parameter in `{%include filepath %}`, `{%layout filepath%}` as a variable, otherwise as a literal value. Defaults to `true`. */
dynamicPartials?: boolean;
/** `strict_filters` is used to enable strict filter existence. If set to `false`, undefined filters will be rendered as empty string. Otherwise, undefined filters will cause an exception. Defaults to `false`. */
strict_filters?: boolean;
/** `strict_variables` is used to enable strict variable derivation. If set to `false`, undefined variables will be rendered as empty string. Otherwise, undefined variables will cause an exception. Defaults to `false`. */
strict_variables?: boolean;
/** `trim_tag_right` is used to strip blank characters (including ` `, `\t`, and `\r`) from the right of tags (`{% %}`) until `\n` (inclusive). Defaults to `false`. */
trim_tag_right?: boolean;
/** `trim_tag_left` is similar to `trim_tag_right`, whereas the `\n` is exclusive. Defaults to `false`. See Whitespace Control for details. */
trim_tag_left?: boolean;
/** ``trim_value_right` is used to strip blank characters (including ` `, `\t`, and `\r`) from the right of values (`{{ }}`) until `\n` (inclusive). Defaults to `false`. */
trim_value_right?: boolean;
/** `trim_value_left` is similar to `trim_value_right`, whereas the `\n` is exclusive. Defaults to `false`. See Whitespace Control for details. */
trim_value_left?: boolean;
/** `greedy` is used to specify whether `trim_left`/`trim_right` is greedy. When set to `true`, all consecutive blank characters including `\n` will be trimed regardless of line breaks. Defaults to `true`. */
greedy?: boolean;
}
export interface NormalizedOptions extends LiquidOptions {
root?: string[];
}
export declare const defaultOptions: NormalizedOptions;
export declare function normalize(options: LiquidOptions): NormalizedOptions;
+1306 -1312
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
File diff suppressed because one or more lines are too long
+30
View File
@@ -0,0 +1,30 @@
import Scope from './scope/scope';
import * as Types from './types';
import ITemplate from './template/itemplate';
import ITagImplOptions from './template/tag/itag-impl-options';
import { isTruthy, isFalsy, evalExp, evalValue } from './render/syntax';
import { LiquidOptions, NormalizedOptions } from './liquid-options';
export default class Liquid {
options: NormalizedOptions;
private cache;
private parser;
private renderer;
private tokenizer;
constructor(opts?: LiquidOptions);
parse(html: string, filepath?: string): any[];
render(tpl: Array<ITemplate>, ctx?: object, opts?: LiquidOptions): Promise<string>;
parseAndRender(html: string, ctx?: object, opts?: LiquidOptions): Promise<string>;
getTemplate(file: any, opts?: LiquidOptions): Promise<any>;
renderFile(file: any, ctx?: object, opts?: LiquidOptions): Promise<string>;
evalValue(str: string, scope: Scope): any;
registerFilter(name: any, filter: any): void;
registerTag(name: string, tag: ITagImplOptions): void;
plugin(plugin: any): any;
express(): (filePath: string, ctx: object, cb: (err: Error, html?: string) => void) => void;
static default: typeof Liquid;
static isTruthy: typeof isTruthy;
static isFalsy: typeof isFalsy;
static evalExp: typeof evalExp;
static evalValue: typeof evalValue;
static Types: typeof Types;
}
+1287 -1246
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+6
View File
@@ -0,0 +1,6 @@
import Token from './token';
export default class DelimitedToken extends Token {
trimLeft: boolean;
trimRight: boolean;
constructor(raw: any, pos: any, input: any, file: any, line: any);
}
+4
View File
@@ -0,0 +1,4 @@
import Token from './token';
export default class HTMLToken extends Token {
constructor(str: any, begin: any, input: any, file: any, line: any);
}
+35
View File
@@ -0,0 +1,35 @@
export declare const quoted: RegExp;
export declare const quoteBalanced: RegExp;
export declare const integer: RegExp;
export declare const number: RegExp;
export declare const bool: RegExp;
export declare const identifier: RegExp;
export declare const subscript: RegExp;
export declare const literal: RegExp;
export declare const variable: RegExp;
export declare const rangeLimit: RegExp;
export declare const range: RegExp;
export declare const rangeCapture: RegExp;
export declare const value: RegExp;
export declare const hash: RegExp;
export declare const hashCapture: RegExp;
export declare const tagLine: RegExp;
export declare const literalLine: RegExp;
export declare const variableLine: RegExp;
export declare const numberLine: RegExp;
export declare const boolLine: RegExp;
export declare const quotedLine: RegExp;
export declare const rangeLine: RegExp;
export declare const integerLine: RegExp;
export declare const valueDeclaration: RegExp;
export declare const valueList: RegExp;
export declare const filter: RegExp;
export declare const filterCapture: RegExp;
export declare const filterLine: RegExp;
export declare const operators: RegExp[];
export declare function isInteger(str: any): boolean;
export declare function isLiteral(str: any): boolean;
export declare function isRange(str: any): boolean;
export declare function isVariable(str: any): boolean;
export declare function matchValue(str: any): RegExpExecArray;
export declare function parseLiteral(str: any): any;
+4
View File
@@ -0,0 +1,4 @@
import DelimitedToken from './delimited-token';
export default class OutputToken extends DelimitedToken {
constructor(raw: any, pos: any, input: any, file: any, line: any);
}
+16
View File
@@ -0,0 +1,16 @@
import Token from 'src/parser/token';
import ITemplate from 'src/template/itemplate';
declare type parseToken = (token: Token, remainTokens: Array<Token>) => ITemplate;
declare type eventHandler = ((arg?: Token | ITemplate) => void);
export default class ParseStream {
private tokens;
private handlers;
private stopRequested;
private parseToken;
constructor(tokens: Array<Token>, parseToken: parseToken);
on(name: string, cb: eventHandler): this;
trigger(event: string, arg?: Token | ITemplate): boolean;
start(): this;
stop(): this;
}
export {};
+13
View File
@@ -0,0 +1,13 @@
import Liquid from 'src/liquid';
import ParseStream from './parse-stream';
import Token from './token';
import Tag from 'src/template/tag/tag';
import Output from 'src/template/output';
import HTML from 'src/template/html';
export default class Parser {
liquid: Liquid;
constructor(liquid: Liquid);
parse(tokens: Array<Token>): any[];
parseToken(token: Token, remainTokens: Array<Token>): Tag | Output | HTML;
parseStream(tokens: Array<Token>): ParseStream;
}
+6
View File
@@ -0,0 +1,6 @@
import DelimitedToken from './delimited-token';
export default class TagToken extends DelimitedToken {
name: string;
args: string;
constructor(raw: any, pos: any, input: any, file: any, line: any);
}
+9
View File
@@ -0,0 +1,9 @@
export default class Token {
type: string;
line: number;
raw: string;
input: string;
file: string;
value: string;
constructor(raw: any, pos: any, input: any, file: any, line: any);
}
+6
View File
@@ -0,0 +1,6 @@
import { LiquidOptions } from 'src/liquid-options';
export default class Tokenizer {
options: LiquidOptions;
constructor(options?: LiquidOptions);
tokenize(input: string, file?: string): any[];
}
+3
View File
@@ -0,0 +1,3 @@
import Token from 'src/parser/token';
import { LiquidOptions } from 'src/liquid-options';
export default function whiteSpaceCtrl(tokens: Token[], options: LiquidOptions): void;
+3
View File
@@ -0,0 +1,3 @@
export default class Render {
renderTemplates(templates: any, scope: any): Promise<string>;
}
+4
View File
@@ -0,0 +1,4 @@
export declare function evalExp(exp: any, scope: any): any;
export declare function evalValue(str: any, scope: any): any;
export declare function isTruthy(val: any): boolean;
export declare function isFalsy(val: any): boolean;
+5
View File
@@ -0,0 +1,5 @@
declare enum BlockMode {
OUTPUT = 0,
STORE = 1
}
export default BlockMode;
+18
View File
@@ -0,0 +1,18 @@
import { NormalizedOptions } from '../liquid-options';
import BlockMode from './block-mode';
export default class Scope {
opts: NormalizedOptions;
contexts: Array<object>;
blocks: object;
blockMode: BlockMode;
constructor(ctx?: object, opts?: NormalizedOptions);
getAll(): object;
get(path: string): any;
set(path: string, v: any): void;
unshift(ctx: object): number;
push(ctx: object): number;
pop(ctx?: object): object;
findContextFor(key: string, filter?: ((conttext: object) => boolean)): object;
readProperty(obj: any, key: any): any;
propertyAccessSeq(str: any): any[];
}
+8
View File
@@ -0,0 +1,8 @@
export declare class CaptureScope {
}
export declare class AssignScope {
}
export declare class IncrementScope {
}
export declare class DecrementScope {
}
+14
View File
@@ -0,0 +1,14 @@
import Scope from 'src/scope/scope';
declare type impl = (value: any, ...args: any[]) => any;
export default class Filter {
name: string;
impl: impl;
args: string[];
private static impls;
constructor(str: string, strictFilters?: boolean);
parseArgs(argList: string): string[];
render(value: any, scope: Scope): any;
static register(name: any, filter: any): void;
static clear(): void;
}
export {};
+8
View File
@@ -0,0 +1,8 @@
import Template from 'src/template/template';
import ITemplate from 'src/template/itemplate';
import Token from 'src/parser/token';
export default class extends Template implements ITemplate {
str: string;
constructor(token: Token);
render(): Promise<string>;
}
+6
View File
@@ -0,0 +1,6 @@
import Scope from 'src/scope/scope';
import Token from 'src/parser/token';
export default interface ITemplate {
token: Token;
render(scope: Scope): Promise<string>;
}
+10
View File
@@ -0,0 +1,10 @@
import Value from './value';
import Template from 'src/template/template';
import ITemplate from 'src/template/itemplate';
import Scope from 'src/scope/scope';
import OutputToken from 'src/parser/output-token';
export default class Output extends Template implements ITemplate {
value: Value;
constructor(token: OutputToken, strictFilters?: boolean);
render(scope: Scope): Promise<string>;
}
+10
View File
@@ -0,0 +1,10 @@
/**
* Key-Value Pairs Representing Tag Arguments
* Example:
* For the markup `{% include 'head.html' foo='bar' %}`,
* hash['foo'] === 'bar'
*/
export default class Hash {
[key: string]: any;
constructor(markup: any, scope: any);
}
+9
View File
@@ -0,0 +1,9 @@
import Scope from 'src/scope/scope';
import TagToken from 'src/parser/tag-token';
import Token from 'src/parser/token';
import Hash from 'src/template/tag/hash';
import ITagImpl from './itag-impl';
export default interface ITagImplOptions {
parse?: (this: ITagImpl, token: TagToken, remainingTokens: Array<Token>) => void;
render?: (this: ITagImpl, scope: Scope, hash: Hash) => any | Promise<any>;
}
+5
View File
@@ -0,0 +1,5 @@
import Liquid from 'src/liquid';
import ITagImplOptions from './itag-impl-options';
export default interface ITagImpl extends ITagImplOptions {
liquid: Liquid;
}
+19
View File
@@ -0,0 +1,19 @@
import Scope from 'src/scope/scope';
import ITagImplOptions from './itag-impl-options';
import Liquid from 'src/liquid';
import Template from 'src/template/template';
import ITemplate from 'src/template/itemplate';
import TagToken from 'src/parser/tag-token';
import Token from 'src/parser/token';
export default class Tag extends Template implements ITemplate {
name: string;
token: TagToken;
private impl;
static impls: {
[key: string]: ITagImplOptions;
};
constructor(token: TagToken, tokens: Token[], liquid: Liquid);
render(scope: Scope): Promise<string>;
static register(name: string, tag: ITagImplOptions): void;
static clear(): void;
}
+5
View File
@@ -0,0 +1,5 @@
import Token from 'src/parser/token';
export default class Template {
token: Token;
constructor(token: any);
}
+7
View File
@@ -0,0 +1,7 @@
import Scope from 'src/scope/scope';
export default class {
initial: any;
filters: Array<any>;
constructor(str: string, strictFilters?: boolean);
value(scope: Scope): any;
}
+2
View File
@@ -0,0 +1,2 @@
export { AssignScope, CaptureScope, IncrementScope, DecrementScope } from './scope/scopes';
export { ParseError, TokenizationError, RenderBreakError, AssertionError } from './util/error';
+1
View File
@@ -0,0 +1 @@
export default function (predicate: any, message?: string): void;
+31
View File
@@ -0,0 +1,31 @@
declare abstract class LiquidError {
name: string;
message: string;
stack: string;
private line;
private file;
private input;
private token;
private originalError;
constructor(err: any, token: any);
captureStackTrace(obj: any): void;
}
export declare class TokenizationError extends LiquidError {
constructor(message: any, token: any);
}
export declare class ParseError extends LiquidError {
constructor(err: any, token: any);
}
export declare class RenderError extends LiquidError {
constructor(err: any, tpl: any);
}
export declare class RenderBreakError {
message: string;
resolvedHTML: string;
constructor(message: any);
}
export declare class AssertionError {
message: string;
constructor(message: any);
}
export {};
+2
View File
@@ -0,0 +1,2 @@
export declare function anySeries(iterable: any, iteratee: any): Promise<any>;
export declare function mapSeries(iterable: any, iteratee: any): Promise<any[]>;
+1
View File
@@ -0,0 +1 @@
export default function (d: any, format: any): string;
+15
View File
@@ -0,0 +1,15 @@
export declare function isString(value: any): boolean;
export declare function isFunction(value: any): boolean;
export declare function promisify(fn: any): (...args: any[]) => Promise<{}>;
export declare function stringify(value: any): string;
export declare function create<T1 extends object, T2 extends T1 = T1>(proto: T1): T2;
export declare function isNil(value: any): boolean;
export declare function isArray(value: any): boolean;
export declare function isError(value: any): boolean;
export declare function forOwn(object: any, iteratee: ((val: any, key: string, obj: object) => boolean | void)): any;
export declare function assign(obj: object, ...srcs: object[]): object;
export declare function last(arr: any[]): any;
export declare function uniq(arr: any[]): any[];
export declare function isObject(value: any): boolean;
export declare function range(start: number, stop?: number, step?: number): any[];
export declare function padStart(str: any, length: number, ch?: string): any;
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "liquidjs",
"version": "7.0.0",
"version": "7.0.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
+4 -2
View File
@@ -1,6 +1,6 @@
{
"name": "liquidjs",
"version": "7.0.0",
"version": "7.0.1",
"description": "Liquid template engine by pure JavaScript: compatible to shopify, easy to extend.",
"main": "dist/liquid.common.js",
"types": "dist/liquid.d.ts",
@@ -83,6 +83,8 @@
]
},
"nyc": {
"extension": [ ".ts" ]
"extension": [
".ts"
]
}
}