mirror of
https://github.com/harttle/liquidjs.git
synced 2026-10-03 09:05:14 -07:00
chore(typescript): ship to TypeScript
This commit is contained in:
+2
-1
@@ -2,7 +2,8 @@
|
|||||||
*.log
|
*.log
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
|
|
||||||
# tests
|
# cache
|
||||||
|
.rpt2_cache
|
||||||
coverage/
|
coverage/
|
||||||
.nyc_output/
|
.nyc_output/
|
||||||
|
|
||||||
|
|||||||
Generated
+408
-1139
File diff suppressed because it is too large
Load Diff
+6
-45
@@ -11,13 +11,10 @@
|
|||||||
"unit": "mocha test/unit",
|
"unit": "mocha test/unit",
|
||||||
"e2e": "mocha test/e2e",
|
"e2e": "mocha test/e2e",
|
||||||
"test": "npm run unit && npm run e2e",
|
"test": "npm run unit && npm run e2e",
|
||||||
"coverage": "cross-env NODE_ENV=test nyc --reporter=html npm run unit",
|
"coverage": "nyc --reporter=html npm run unit",
|
||||||
"coveralls": "nyc report --reporter=text-lcov | coveralls",
|
"coveralls": "nyc report --reporter=text-lcov | coveralls",
|
||||||
"build": "rollup -c && ls -lh dist",
|
"build": "rollup -c && ls -lh dist",
|
||||||
"version": "npm run build && git add -A dist",
|
"version": "npm run build && git add -A dist"
|
||||||
"demo:browser": "echo open http://localhost:8080/demo/browser && http-server -c-1",
|
|
||||||
"demo:nodejs": "node ./demo/nodejs/index.js",
|
|
||||||
"demo:express": "cd ./demo/express/ && npm start"
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -45,12 +42,6 @@
|
|||||||
"@semantic-release/git": "^7.0.8",
|
"@semantic-release/git": "^7.0.8",
|
||||||
"@semantic-release/npm": "^5.1.4",
|
"@semantic-release/npm": "^5.1.4",
|
||||||
"@semantic-release/release-notes-generator": "^7.1.4",
|
"@semantic-release/release-notes-generator": "^7.1.4",
|
||||||
"babel-core": "^6.26.3",
|
|
||||||
"babel-plugin-external-helpers": "^6.22.0",
|
|
||||||
"babel-plugin-istanbul": "^5.1.0",
|
|
||||||
"babel-plugin-transform-runtime": "^6.23.0",
|
|
||||||
"babel-preset-env": "^1.7.0",
|
|
||||||
"babel-runtime": "^6.26.0",
|
|
||||||
"chai": "^4.2.0",
|
"chai": "^4.2.0",
|
||||||
"chai-as-promised": "^7.1.1",
|
"chai-as-promised": "^7.1.1",
|
||||||
"coveralls": "^3.0.2",
|
"coveralls": "^3.0.2",
|
||||||
@@ -63,7 +54,6 @@
|
|||||||
"eslint-plugin-promise": "^4.0.1",
|
"eslint-plugin-promise": "^4.0.1",
|
||||||
"eslint-plugin-standard": "^4.0.0",
|
"eslint-plugin-standard": "^4.0.0",
|
||||||
"express": "^4.16.4",
|
"express": "^4.16.4",
|
||||||
"http-server": "^0.11.1",
|
|
||||||
"jsdom": "^13.2.0",
|
"jsdom": "^13.2.0",
|
||||||
"mocha": "^5.2.0",
|
"mocha": "^5.2.0",
|
||||||
"mock-fs": "^4.7.0",
|
"mock-fs": "^4.7.0",
|
||||||
@@ -71,14 +61,15 @@
|
|||||||
"regenerator-runtime": "^0.12.1",
|
"regenerator-runtime": "^0.12.1",
|
||||||
"rollup": "^1.1.2",
|
"rollup": "^1.1.2",
|
||||||
"rollup-plugin-alias": "^1.5.1",
|
"rollup-plugin-alias": "^1.5.1",
|
||||||
"rollup-plugin-babel": "^3.0.7",
|
|
||||||
"rollup-plugin-node-resolve": "^3.3.0",
|
|
||||||
"rollup-plugin-shim": "^1.0.0",
|
"rollup-plugin-shim": "^1.0.0",
|
||||||
|
"rollup-plugin-typescript2": "^0.19.2",
|
||||||
"rollup-plugin-uglify": "^6.0.2",
|
"rollup-plugin-uglify": "^6.0.2",
|
||||||
"semantic-release": "^15.13.3",
|
"semantic-release": "^15.13.3",
|
||||||
"sinon": "^7.2.3",
|
"sinon": "^7.2.3",
|
||||||
"sinon-chai": "^3.3.0",
|
"sinon-chai": "^3.3.0",
|
||||||
"supertest": "^3.4.2"
|
"supertest": "^3.4.2",
|
||||||
|
"ts-node": "^8.0.2",
|
||||||
|
"typescript": "^3.3.3"
|
||||||
},
|
},
|
||||||
"release": {
|
"release": {
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
@@ -89,35 +80,5 @@
|
|||||||
"@semantic-release/npm",
|
"@semantic-release/npm",
|
||||||
"@semantic-release/git"
|
"@semantic-release/git"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"nyc": {
|
|
||||||
"require": [
|
|
||||||
"babel-core/register"
|
|
||||||
],
|
|
||||||
"sourceMap": false,
|
|
||||||
"instrument": false
|
|
||||||
},
|
|
||||||
"babel": {
|
|
||||||
"presets": [
|
|
||||||
"env"
|
|
||||||
],
|
|
||||||
"plugins": [
|
|
||||||
[
|
|
||||||
"transform-runtime",
|
|
||||||
{
|
|
||||||
"helpers": false,
|
|
||||||
"polyfill": false,
|
|
||||||
"regenerator": true,
|
|
||||||
"moduleName": "babel-runtime"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"env": {
|
|
||||||
"test": {
|
|
||||||
"plugins": [
|
|
||||||
"istanbul"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-19
@@ -1,9 +1,8 @@
|
|||||||
import shim from 'rollup-plugin-shim'
|
import shim from 'rollup-plugin-shim'
|
||||||
import alias from 'rollup-plugin-alias'
|
import alias from 'rollup-plugin-alias'
|
||||||
import babel from 'rollup-plugin-babel'
|
|
||||||
import { uglify } from 'rollup-plugin-uglify'
|
import { uglify } from 'rollup-plugin-uglify'
|
||||||
import pkg from './package.json'
|
import pkg from './package.json'
|
||||||
import nodeResolve from 'rollup-plugin-node-resolve'
|
import typescript from 'rollup-plugin-typescript2'
|
||||||
|
|
||||||
const fake = { fs: `export default {}`, path: `export default {}` }
|
const fake = { fs: `export default {}`, path: `export default {}` }
|
||||||
const version = process.env.VERSION || pkg.version
|
const version = process.env.VERSION || pkg.version
|
||||||
@@ -16,12 +15,10 @@ const banner = `/*
|
|||||||
const treeshake = {
|
const treeshake = {
|
||||||
propertyReadSideEffects: false
|
propertyReadSideEffects: false
|
||||||
}
|
}
|
||||||
const input = 'src/index.js'
|
const input = 'src/index.ts'
|
||||||
|
const tsOptions = {
|
||||||
const babelConf = {
|
include: [ '*.ts', '**/*.ts', '*.js', '**/*.js' ],
|
||||||
babelrc: false,
|
tsconfigOverride: { compilerOptions: { module: 'ES2015' } }
|
||||||
'presets': [['env', { 'modules': false }]],
|
|
||||||
'plugins': ['external-helpers']
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default [{
|
export default [{
|
||||||
@@ -33,10 +30,7 @@ export default [{
|
|||||||
banner
|
banner
|
||||||
}],
|
}],
|
||||||
external: ['path', 'fs'],
|
external: ['path', 'fs'],
|
||||||
plugins: [
|
plugins: [typescript(tsOptions)],
|
||||||
nodeResolve(),
|
|
||||||
babel(babelConf)
|
|
||||||
],
|
|
||||||
treeshake,
|
treeshake,
|
||||||
input
|
input
|
||||||
}, {
|
}, {
|
||||||
@@ -49,11 +43,8 @@ export default [{
|
|||||||
}],
|
}],
|
||||||
plugins: [
|
plugins: [
|
||||||
shim(fake),
|
shim(fake),
|
||||||
alias({
|
alias({ './template': './template-browser' }),
|
||||||
'./template': './template-browser'
|
typescript(tsOptions)
|
||||||
}),
|
|
||||||
nodeResolve(),
|
|
||||||
babel(babelConf)
|
|
||||||
],
|
],
|
||||||
treeshake,
|
treeshake,
|
||||||
input
|
input
|
||||||
@@ -66,8 +57,8 @@ export default [{
|
|||||||
}],
|
}],
|
||||||
plugins: [
|
plugins: [
|
||||||
shim(fake),
|
shim(fake),
|
||||||
nodeResolve(),
|
alias({ './template': './template-browser' }),
|
||||||
babel(babelConf),
|
typescript(tsOptions),
|
||||||
uglify()
|
uglify()
|
||||||
],
|
],
|
||||||
treeshake,
|
treeshake,
|
||||||
|
|||||||
+4
-4
@@ -1,7 +1,7 @@
|
|||||||
import * as lexical from './lexical.js'
|
import * as lexical from './lexical'
|
||||||
import { evalValue } from './syntax.js'
|
import { evalValue } from './syntax'
|
||||||
import assert from './util/assert.js'
|
import assert from './util/assert'
|
||||||
import { assign, create } from './util/underscore.js'
|
import { assign, create } from './util/underscore'
|
||||||
|
|
||||||
const valueRE = new RegExp(`${lexical.value.source}`, 'g')
|
const valueRE = new RegExp(`${lexical.value.source}`, 'g')
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -1,6 +1,6 @@
|
|||||||
import strftime from './util/strftime.js'
|
import strftime from './util/strftime'
|
||||||
import * as _ from './util/underscore.js'
|
import * as _ from './util/underscore'
|
||||||
import { isTruthy } from './syntax.js'
|
import { isTruthy } from './syntax'
|
||||||
|
|
||||||
const escapeMap = {
|
const escapeMap = {
|
||||||
'&': '&',
|
'&': '&',
|
||||||
@@ -132,7 +132,7 @@ function isValidDate (date) {
|
|||||||
return date instanceof Date && !isNaN(date.getTime())
|
return date instanceof Date && !isNaN(date.getTime())
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function registerAll (liquid) {
|
export default function registerAll (liquid, Liquid) {
|
||||||
return _.forOwn(filters, (func, name) => liquid.registerFilter(name, func))
|
return _.forOwn(filters, (func, name) => liquid.registerFilter(name, func))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
-69
@@ -1,69 +0,0 @@
|
|||||||
export as namespace Liquid;
|
|
||||||
|
|
||||||
export function isTruthy(val: any): boolean;
|
|
||||||
export function isFalsy(val: any): boolean;
|
|
||||||
export function evalExp(exp: string, scope: any): any;
|
|
||||||
export function evalValue(str: string, scope: any): any;
|
|
||||||
|
|
||||||
export default class Liquid {
|
|
||||||
constructor(options?: Options);
|
|
||||||
private init(tag, filter, options): Liquid;
|
|
||||||
private respectCache(key, getter): Promise<any>
|
|
||||||
parse(html: string, filepath?: string): Liquid.Template
|
|
||||||
render(tpl: Template, ctx: any, opts?: Options): Promise<string>
|
|
||||||
parseAndRender(html: string, ctx: any, opts?: Options): Promise<string>
|
|
||||||
renderFile(file: string, ctx: any, opts?: Options): Promise<string>
|
|
||||||
getTemplate(file: string, root: string): Promise<Liquid.Template>
|
|
||||||
registerFilter(name: string, filter: Filter): void
|
|
||||||
registerTag(name: string, tag: Tag): void
|
|
||||||
express(opts: Options): any
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Options {
|
|
||||||
/** `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
|
|
||||||
/** `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 Template { }
|
|
||||||
|
|
||||||
export interface Tag {
|
|
||||||
parse(this: any, tagToken: any, remainTokens: any): void
|
|
||||||
render(this: any, scope: any, hash: any): void
|
|
||||||
}
|
|
||||||
export type Filter = (...args: any) => string
|
|
||||||
|
|
||||||
declare namespace Types {
|
|
||||||
class LiquidError extends Error {
|
|
||||||
input: string
|
|
||||||
line: number
|
|
||||||
file: string
|
|
||||||
}
|
|
||||||
class ParseError extends LiquidError {
|
|
||||||
originalError: Error
|
|
||||||
}
|
|
||||||
class TokenizationError extends LiquidError {}
|
|
||||||
class RenderBreakError extends LiquidError {}
|
|
||||||
class AssertionError extends LiquidError {}
|
|
||||||
class AssignScope {}
|
|
||||||
class CaptureScope {}
|
|
||||||
class IncrementScope {}
|
|
||||||
class DecrementScope {}
|
|
||||||
}
|
|
||||||
+12
-13
@@ -1,17 +1,16 @@
|
|||||||
import 'regenerator-runtime/runtime'
|
import Scope from './scope'
|
||||||
import * as Scope from './scope'
|
|
||||||
import * as template from './template'
|
import * as template from './template'
|
||||||
import * as _ from './util/underscore.js'
|
import * as _ from './util/underscore'
|
||||||
import assert from './util/assert.js'
|
import assert from './util/assert'
|
||||||
import * as tokenizer from './tokenizer.js'
|
import * as tokenizer from './tokenizer'
|
||||||
import Render from './render.js'
|
import Render from './render'
|
||||||
import Tag from './tag.js'
|
import Tag from './tag'
|
||||||
import Filter from './filter.js'
|
import Filter from './filter'
|
||||||
import Parser from './parser'
|
import Parser from './parser'
|
||||||
import { isTruthy, isFalsy, evalExp, evalValue } from './syntax.js'
|
import { isTruthy, isFalsy, evalExp, evalValue } from './syntax'
|
||||||
import { ParseError, TokenizationError, RenderBreakError, AssertionError } from './util/error.js'
|
import { ParseError, TokenizationError, RenderBreakError, AssertionError } from './util/error'
|
||||||
import tags from './tags/index.js'
|
import tags from './tags/index'
|
||||||
import filters from './filters.js'
|
import filters from './filters'
|
||||||
|
|
||||||
const _engine = {
|
const _engine = {
|
||||||
init: function (tag, filter, options) {
|
init: function (tag, filter, options) {
|
||||||
@@ -35,7 +34,7 @@ const _engine = {
|
|||||||
},
|
},
|
||||||
render: function (tpl, ctx, opts) {
|
render: function (tpl, ctx, opts) {
|
||||||
opts = _.assign({}, this.options, opts)
|
opts = _.assign({}, this.options, opts)
|
||||||
const scope = Scope.factory(ctx, opts)
|
const scope = new Scope(ctx, opts)
|
||||||
return this.renderer.renderTemplates(tpl, scope)
|
return this.renderer.renderTemplates(tpl, scope)
|
||||||
},
|
},
|
||||||
parseAndRender: async function (html, ctx, opts) {
|
parseAndRender: async function (html, ctx, opts) {
|
||||||
@@ -1,27 +1,28 @@
|
|||||||
import * as lexical from './lexical.js'
|
import * as lexical from './lexical'
|
||||||
import { create } from './util/underscore.js'
|
import { ParseError } from './util/error'
|
||||||
import { ParseError } from './util/error.js'
|
import assert from './util/assert'
|
||||||
import assert from './util/assert.js'
|
|
||||||
|
|
||||||
export default function (Tag, Filter) {
|
export default function (Tag, Filter) {
|
||||||
const stream = {
|
class ParseStream {
|
||||||
init: function (tokens) {
|
tokens: Array<any>
|
||||||
|
handlers: object
|
||||||
|
stopRequested: boolean
|
||||||
|
constructor (tokens) {
|
||||||
this.tokens = tokens
|
this.tokens = tokens
|
||||||
this.handlers = {}
|
this.handlers = {}
|
||||||
return this
|
}
|
||||||
},
|
on (name, cb) {
|
||||||
on: function (name, cb) {
|
|
||||||
this.handlers[name] = cb
|
this.handlers[name] = cb
|
||||||
return this
|
return this
|
||||||
},
|
}
|
||||||
trigger: function (event, arg) {
|
trigger (event: string, arg?: any) {
|
||||||
const h = this.handlers[event]
|
const h = this.handlers[event]
|
||||||
if (typeof h === 'function') {
|
if (typeof h === 'function') {
|
||||||
h(arg)
|
h(arg)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
start: function () {
|
start () {
|
||||||
this.trigger('start')
|
this.trigger('start')
|
||||||
let token
|
let token
|
||||||
while (!this.stopRequested && (token = this.tokens.shift())) {
|
while (!this.stopRequested && (token = this.tokens.shift())) {
|
||||||
@@ -35,8 +36,8 @@ export default function (Tag, Filter) {
|
|||||||
}
|
}
|
||||||
if (!this.stopRequested) this.trigger('end')
|
if (!this.stopRequested) this.trigger('end')
|
||||||
return this
|
return this
|
||||||
},
|
}
|
||||||
stop: function () {
|
stop () {
|
||||||
this.stopRequested = true
|
this.stopRequested = true
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
@@ -93,8 +94,7 @@ export default function (Tag, Filter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parseStream (tokens) {
|
function parseStream (tokens) {
|
||||||
const s = create(stream)
|
return new ParseStream(tokens)
|
||||||
return s.init(tokens)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
+5
-5
@@ -1,7 +1,7 @@
|
|||||||
import { evalExp } from './syntax.js'
|
import { evalExp } from './syntax'
|
||||||
import { RenderBreakError, RenderError } from './util/error.js'
|
import { RenderBreakError, RenderError } from './util/error'
|
||||||
import { stringify, create } from './util/underscore.js'
|
import { stringify, create } from './util/underscore'
|
||||||
import assert from './util/assert.js'
|
import assert from './util/assert'
|
||||||
|
|
||||||
const render = {
|
const render = {
|
||||||
renderTemplates: async function (templates, scope) {
|
renderTemplates: async function (templates, scope) {
|
||||||
@@ -16,7 +16,7 @@ const render = {
|
|||||||
e.resolvedHTML = html
|
e.resolvedHTML = html
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
throw new RenderError(e, tpl)
|
throw e instanceof RenderError ? e : new RenderError(e, tpl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return html
|
return html
|
||||||
|
|||||||
+42
-36
@@ -1,17 +1,38 @@
|
|||||||
import * as _ from './util/underscore.js'
|
import * as _ from './util/underscore'
|
||||||
import * as lexical from './lexical.js'
|
import * as lexical from './lexical'
|
||||||
import assert from './util/assert.js'
|
import assert from './util/assert'
|
||||||
|
|
||||||
const Scope = {
|
interface ScopeOptions {
|
||||||
getAll: function () {
|
dynamicPartials: boolean
|
||||||
|
strict_variables: boolean
|
||||||
|
strict_filters: boolean
|
||||||
|
blocks: object
|
||||||
|
root: Array<string>
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Scope {
|
||||||
|
opts: ScopeOptions
|
||||||
|
contexts: Array<object>
|
||||||
|
constructor (ctx = {}, opts?: any) {
|
||||||
|
const defaultOptions: ScopeOptions = {
|
||||||
|
dynamicPartials: true,
|
||||||
|
strict_variables: false,
|
||||||
|
strict_filters: false,
|
||||||
|
blocks: {},
|
||||||
|
root: []
|
||||||
|
}
|
||||||
|
this.opts = _.assign(defaultOptions, opts)
|
||||||
|
this.contexts = [ctx || {}]
|
||||||
|
}
|
||||||
|
getAll () {
|
||||||
return this.contexts.reduce((ctx, val) => _.assign(ctx, val), _.create(null))
|
return this.contexts.reduce((ctx, val) => _.assign(ctx, val), _.create(null))
|
||||||
},
|
}
|
||||||
get: function (path) {
|
get (path) {
|
||||||
const paths = this.propertyAccessSeq(path)
|
const paths = this.propertyAccessSeq(path)
|
||||||
const scope = this.findContextFor(paths[0]) || _.last(this.contexts)
|
const scope = this.findContextFor(paths[0]) || _.last(this.contexts)
|
||||||
return paths.reduce((value, key) => this.readProperty(value, key), scope)
|
return paths.reduce((value, key) => this.readProperty(value, key), scope)
|
||||||
},
|
}
|
||||||
set: function (path, v) {
|
set (path, v) {
|
||||||
const paths = this.propertyAccessSeq(path)
|
const paths = this.propertyAccessSeq(path)
|
||||||
let scope = this.findContextFor(paths[0]) || _.last(this.contexts)
|
let scope = this.findContextFor(paths[0]) || _.last(this.contexts)
|
||||||
paths.some((key, i) => {
|
paths.some((key, i) => {
|
||||||
@@ -27,14 +48,14 @@ const Scope = {
|
|||||||
}
|
}
|
||||||
scope = scope[key]
|
scope = scope[key]
|
||||||
})
|
})
|
||||||
},
|
}
|
||||||
unshift: function (ctx) {
|
unshift (ctx) {
|
||||||
return this.contexts.unshift(ctx)
|
return this.contexts.unshift(ctx)
|
||||||
},
|
}
|
||||||
push: function (ctx) {
|
push (ctx) {
|
||||||
return this.contexts.push(ctx)
|
return this.contexts.push(ctx)
|
||||||
},
|
}
|
||||||
pop: function (ctx) {
|
pop (ctx) {
|
||||||
if (!arguments.length) {
|
if (!arguments.length) {
|
||||||
return this.contexts.pop()
|
return this.contexts.pop()
|
||||||
}
|
}
|
||||||
@@ -43,9 +64,8 @@ const Scope = {
|
|||||||
throw new TypeError('scope not found, cannot pop')
|
throw new TypeError('scope not found, cannot pop')
|
||||||
}
|
}
|
||||||
return this.contexts.splice(i, 1)[0]
|
return this.contexts.splice(i, 1)[0]
|
||||||
},
|
}
|
||||||
findContextFor: function (key, filter) {
|
findContextFor (key, filter = (arg => true)) {
|
||||||
filter = filter || (() => true)
|
|
||||||
for (let i = this.contexts.length - 1; i >= 0; i--) {
|
for (let i = this.contexts.length - 1; i >= 0; i--) {
|
||||||
const candidate = this.contexts[i]
|
const candidate = this.contexts[i]
|
||||||
if (!filter(candidate)) continue
|
if (!filter(candidate)) continue
|
||||||
@@ -54,8 +74,8 @@ const Scope = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
},
|
}
|
||||||
readProperty: function (obj, key) {
|
readProperty (obj, key) {
|
||||||
let val
|
let val
|
||||||
if (_.isNil(obj)) {
|
if (_.isNil(obj)) {
|
||||||
val = undefined
|
val = undefined
|
||||||
@@ -70,7 +90,7 @@ const Scope = {
|
|||||||
throw new TypeError(`undefined variable: ${key}`)
|
throw new TypeError(`undefined variable: ${key}`)
|
||||||
}
|
}
|
||||||
return val
|
return val
|
||||||
},
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse property access sequence from access string
|
* Parse property access sequence from access string
|
||||||
@@ -80,7 +100,7 @@ const Scope = {
|
|||||||
* accessSeq("foo['b]r']") // ['foo', 'b]r']
|
* accessSeq("foo['b]r']") // ['foo', 'b]r']
|
||||||
* accessSeq("foo[bar.coo]") // ['foo', 'bar'], for bar.coo == 'bar'
|
* accessSeq("foo[bar.coo]") // ['foo', 'bar'], for bar.coo == 'bar'
|
||||||
*/
|
*/
|
||||||
propertyAccessSeq: function (str) {
|
propertyAccessSeq (str) {
|
||||||
str = String(str)
|
str = String(str)
|
||||||
const seq = []
|
const seq = []
|
||||||
let name = ''
|
let name = ''
|
||||||
@@ -163,17 +183,3 @@ function matchRightBracket (str, begin) {
|
|||||||
}
|
}
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
export function factory (ctx, opts) {
|
|
||||||
const defaultOptions = {
|
|
||||||
dynamicPartials: true,
|
|
||||||
strict_variables: false,
|
|
||||||
strict_filters: false,
|
|
||||||
blocks: {},
|
|
||||||
root: []
|
|
||||||
}
|
|
||||||
const scope = _.create(Scope)
|
|
||||||
scope.opts = _.assign(defaultOptions, opts)
|
|
||||||
scope.contexts = [ctx || {}]
|
|
||||||
return scope
|
|
||||||
}
|
|
||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
import Operators from './operators.js'
|
import Operators from './operators'
|
||||||
import * as lexical from './lexical.js'
|
import * as lexical from './lexical'
|
||||||
import assert from './util/assert.js'
|
import assert from './util/assert'
|
||||||
|
|
||||||
const operators = Operators(isTruthy)
|
const operators = Operators(isTruthy)
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -1,7 +1,7 @@
|
|||||||
import { hashCapture } from './lexical.js'
|
import { hashCapture } from './lexical'
|
||||||
import { create } from './util/underscore.js'
|
import { create } from './util/underscore'
|
||||||
import { evalValue } from './syntax.js'
|
import { evalValue } from './syntax'
|
||||||
import assert from './util/assert.js'
|
import assert from './util/assert'
|
||||||
|
|
||||||
function hash (markup, scope) {
|
function hash (markup, scope) {
|
||||||
const obj = {}
|
const obj = {}
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
import assert from '../util/assert.js'
|
import assert from '../util/assert'
|
||||||
import { identifier } from '../lexical.js'
|
import { identifier } from '../lexical'
|
||||||
import { create } from '../util/underscore.js'
|
import { create } from '../util/underscore'
|
||||||
|
|
||||||
export default function (liquid, Liquid) {
|
export default function (liquid, Liquid) {
|
||||||
const re = new RegExp(`(${identifier.source})\\s*=([^]*)`)
|
const re = new RegExp(`(${identifier.source})\\s*=([^]*)`)
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
import assert from '../util/assert.js'
|
import assert from '../util/assert'
|
||||||
import { create } from '../util/underscore.js'
|
import { create } from '../util/underscore'
|
||||||
import { identifier } from '../lexical.js'
|
import { identifier } from '../lexical'
|
||||||
|
|
||||||
export default function (liquid, Liquid) {
|
export default function (liquid, Liquid) {
|
||||||
const re = new RegExp(`(${identifier.source})`)
|
const re = new RegExp(`(${identifier.source})`)
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
import assert from '../util/assert.js'
|
import assert from '../util/assert'
|
||||||
import { value as rValue } from '../lexical.js'
|
import { value as rValue } from '../lexical'
|
||||||
|
|
||||||
export default function (liquid, Liquid) {
|
export default function (liquid, Liquid) {
|
||||||
const groupRE = new RegExp(`^(?:(${rValue.source})\\s*:\\s*)?(.*)$`)
|
const groupRE = new RegExp(`^(?:(${rValue.source})\\s*:\\s*)?(.*)$`)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { create } from '../util/underscore.js'
|
import { create } from '../util/underscore'
|
||||||
import assert from '../util/assert.js'
|
import assert from '../util/assert'
|
||||||
import { identifier } from '../lexical.js'
|
import { identifier } from '../lexical'
|
||||||
|
|
||||||
export default function (liquid, Liquid) {
|
export default function (liquid, Liquid) {
|
||||||
const { CaptureScope, AssignScope, DecrementScope } = Liquid.Types
|
const { CaptureScope, AssignScope, DecrementScope } = Liquid.Types
|
||||||
|
|||||||
+4
-4
@@ -1,7 +1,7 @@
|
|||||||
import { mapSeries } from '../util/promise.js'
|
import { mapSeries } from '../util/promise'
|
||||||
import { isString, isObject, isArray } from '../util/underscore.js'
|
import { isString, isObject, isArray } from '../util/underscore'
|
||||||
import assert from '../util/assert.js'
|
import assert from '../util/assert'
|
||||||
import { identifier, value, hash } from '../lexical.js'
|
import { identifier, value, hash } from '../lexical'
|
||||||
|
|
||||||
export default function (liquid, Liquid) {
|
export default function (liquid, Liquid) {
|
||||||
const RenderBreakError = Liquid.Types.RenderBreakError
|
const RenderBreakError = Liquid.Types.RenderBreakError
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
import assert from '../util/assert.js'
|
import assert from '../util/assert'
|
||||||
import { value, quotedLine } from '../lexical.js'
|
import { value, quotedLine } from '../lexical'
|
||||||
|
|
||||||
const staticFileRE = /[^\s,]+/
|
const staticFileRE = /[^\s,]+/
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import assert from '../util/assert.js'
|
import assert from '../util/assert'
|
||||||
import { create } from '../util/underscore.js'
|
import { create } from '../util/underscore'
|
||||||
import { identifier } from '../lexical.js'
|
import { identifier } from '../lexical'
|
||||||
|
|
||||||
export default function (liquid, Liquid) {
|
export default function (liquid, Liquid) {
|
||||||
const { CaptureScope, AssignScope, IncrementScope } = Liquid.Types
|
const { CaptureScope, AssignScope, IncrementScope } = Liquid.Types
|
||||||
|
|||||||
+14
-14
@@ -1,17 +1,17 @@
|
|||||||
import For from './for.js'
|
import For from './for'
|
||||||
import Assign from './assign.js'
|
import Assign from './assign'
|
||||||
import Capture from './capture.js'
|
import Capture from './capture'
|
||||||
import Case from './case.js'
|
import Case from './case'
|
||||||
import Comment from './comment.js'
|
import Comment from './comment'
|
||||||
import Include from './include.js'
|
import Include from './include'
|
||||||
import Decrement from './decrement.js'
|
import Decrement from './decrement'
|
||||||
import Cycle from './cycle.js'
|
import Cycle from './cycle'
|
||||||
import If from './if.js'
|
import If from './if'
|
||||||
import Increment from './increment.js'
|
import Increment from './increment'
|
||||||
import Layout from './layout.js'
|
import Layout from './layout'
|
||||||
import Raw from './raw.js'
|
import Raw from './raw'
|
||||||
import Tablerow from './tablerow.js'
|
import Tablerow from './tablerow'
|
||||||
import Unless from './unless.js'
|
import Unless from './unless'
|
||||||
|
|
||||||
export default function (engine, Liquid) {
|
export default function (engine, Liquid) {
|
||||||
Assign(engine, Liquid)
|
Assign(engine, Liquid)
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
import assert from '../util/assert.js'
|
import assert from '../util/assert'
|
||||||
import { value as rValue } from '../lexical.js'
|
import { value as rValue } from '../lexical'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* blockMode:
|
* blockMode:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { mapSeries } from '../util/promise.js'
|
import { mapSeries } from '../util/promise'
|
||||||
import assert from '../util/assert.js'
|
import assert from '../util/assert'
|
||||||
import { identifier, value, hash } from '../lexical.js'
|
import { identifier, value, hash } from '../lexical'
|
||||||
|
|
||||||
export default function (liquid, Liquid) {
|
export default function (liquid, Liquid) {
|
||||||
const re = new RegExp(`^(${identifier.source})\\s+in\\s+` +
|
const re = new RegExp(`^(${identifier.source})\\s+in\\s+` +
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as _ from './util/underscore.js'
|
import * as _ from './util/underscore'
|
||||||
import path from 'path'
|
import * as path from 'path'
|
||||||
import { anySeries } from './util/promise.js'
|
import { anySeries } from './util/promise'
|
||||||
import fs from 'fs'
|
import * as fs from 'fs'
|
||||||
|
|
||||||
const statFileAsync = _.promisify(fs.stat)
|
const statFileAsync = _.promisify(fs.stat)
|
||||||
const readFileAsync = _.promisify(fs.readFile)
|
const readFileAsync = _.promisify(fs.readFile)
|
||||||
+6
-6
@@ -1,10 +1,10 @@
|
|||||||
import * as lexical from './lexical.js'
|
import * as lexical from './lexical'
|
||||||
import { TokenizationError } from './util/error.js'
|
import { TokenizationError } from './util/error'
|
||||||
import * as _ from './util/underscore.js'
|
import * as _ from './util/underscore'
|
||||||
import assert from './util/assert.js'
|
import assert from './util/assert'
|
||||||
import whiteSpaceCtrl from './whitespace-ctrl.js'
|
import whiteSpaceCtrl from './whitespace-ctrl'
|
||||||
|
|
||||||
export { default as whiteSpaceCtrl } from './whitespace-ctrl.js'
|
export { default as whiteSpaceCtrl } from './whitespace-ctrl'
|
||||||
|
|
||||||
export function parse (input, file, options) {
|
export function parse (input, file, options) {
|
||||||
assert(_.isString(input), 'illegal input')
|
assert(_.isString(input), 'illegal input')
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { AssertionError } from './error.js'
|
import { AssertionError } from './error'
|
||||||
|
|
||||||
export default function (predicate, message) {
|
export default function (predicate: any, message: string) {
|
||||||
if (!predicate) {
|
if (!predicate) {
|
||||||
message = message || `expect ${predicate} to be true`
|
message = message || `expect ${predicate} to be true`
|
||||||
throw new AssertionError(message)
|
throw new AssertionError(message)
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
import * as _ from './underscore.js'
|
|
||||||
|
|
||||||
function initError () {
|
|
||||||
this.name = this.constructor.name
|
|
||||||
if (Error.captureStackTrace) {
|
|
||||||
Error.captureStackTrace(this, this.constructor)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function initLiquidError (err, token) {
|
|
||||||
initError.call(this)
|
|
||||||
|
|
||||||
this.input = token.input
|
|
||||||
this.line = token.line
|
|
||||||
this.file = token.file
|
|
||||||
|
|
||||||
const context = mkContext(token.input, token.line)
|
|
||||||
this.message = mkMessage(err.message, token)
|
|
||||||
this.stack = context +
|
|
||||||
'\n' + (this.stack || this.message) +
|
|
||||||
(err.stack ? '\nFrom ' + err.stack : '')
|
|
||||||
}
|
|
||||||
|
|
||||||
export function TokenizationError (message, token) {
|
|
||||||
initLiquidError.call(this, { message: message }, token)
|
|
||||||
}
|
|
||||||
TokenizationError.prototype = _.create(Error.prototype)
|
|
||||||
TokenizationError.prototype.constructor = TokenizationError
|
|
||||||
|
|
||||||
export function ParseError (e, token) {
|
|
||||||
_.assign(this, e)
|
|
||||||
this.originalError = e
|
|
||||||
|
|
||||||
initLiquidError.call(this, e, token)
|
|
||||||
}
|
|
||||||
ParseError.prototype = _.create(Error.prototype)
|
|
||||||
ParseError.prototype.constructor = ParseError
|
|
||||||
|
|
||||||
export function RenderError (e, tpl) {
|
|
||||||
// return the original render error
|
|
||||||
if (e instanceof RenderError) {
|
|
||||||
return e
|
|
||||||
}
|
|
||||||
_.assign(this, e)
|
|
||||||
this.originalError = e
|
|
||||||
|
|
||||||
initLiquidError.call(this, e, tpl.token)
|
|
||||||
}
|
|
||||||
RenderError.prototype = _.create(Error.prototype)
|
|
||||||
RenderError.prototype.constructor = RenderError
|
|
||||||
|
|
||||||
export function RenderBreakError (message) {
|
|
||||||
initError.call(this)
|
|
||||||
this.message = message + ''
|
|
||||||
}
|
|
||||||
RenderBreakError.prototype = _.create(Error.prototype)
|
|
||||||
RenderBreakError.prototype.constructor = RenderBreakError
|
|
||||||
|
|
||||||
export function AssertionError (message) {
|
|
||||||
initError.call(this)
|
|
||||||
this.message = message + ''
|
|
||||||
}
|
|
||||||
AssertionError.prototype = _.create(Error.prototype)
|
|
||||||
AssertionError.prototype.constructor = AssertionError
|
|
||||||
|
|
||||||
function mkContext (input, line) {
|
|
||||||
const lines = input.split('\n')
|
|
||||||
const begin = Math.max(line - 2, 1)
|
|
||||||
const end = Math.min(line + 3, lines.length)
|
|
||||||
|
|
||||||
const context = _
|
|
||||||
.range(begin, end + 1)
|
|
||||||
.map(l => [
|
|
||||||
(l === line) ? '>> ' : ' ',
|
|
||||||
align(l, end),
|
|
||||||
'| ',
|
|
||||||
lines[l - 1]
|
|
||||||
].join(''))
|
|
||||||
.join('\n')
|
|
||||||
|
|
||||||
return context
|
|
||||||
}
|
|
||||||
|
|
||||||
function align (n, max) {
|
|
||||||
const length = (max + '').length
|
|
||||||
const str = n + ''
|
|
||||||
const blank = Array(length - str.length).join(' ')
|
|
||||||
return blank + str
|
|
||||||
}
|
|
||||||
|
|
||||||
function mkMessage (msg, token) {
|
|
||||||
msg = msg || ''
|
|
||||||
if (token.file) {
|
|
||||||
msg += ', file:' + token.file
|
|
||||||
}
|
|
||||||
if (token.line) {
|
|
||||||
msg += ', line:' + token.line
|
|
||||||
}
|
|
||||||
return msg
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
import * as _ from './underscore'
|
||||||
|
|
||||||
|
function captureStack () {
|
||||||
|
if (Error.captureStackTrace) {
|
||||||
|
Error.captureStackTrace(this, this.constructor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class LiquidError {
|
||||||
|
input: string
|
||||||
|
line: string
|
||||||
|
file: string
|
||||||
|
message: string
|
||||||
|
name: string
|
||||||
|
stack: string
|
||||||
|
token: any
|
||||||
|
originalError: any
|
||||||
|
constructor(err, token) {
|
||||||
|
this.input = token.input
|
||||||
|
this.line = token.line
|
||||||
|
this.file = token.file
|
||||||
|
this.originalError = err
|
||||||
|
this.token = token
|
||||||
|
}
|
||||||
|
captureStackTrace(obj) {
|
||||||
|
this.name = obj.constructor.name
|
||||||
|
|
||||||
|
captureStack.call(obj)
|
||||||
|
const err = this.originalError
|
||||||
|
const context = mkContext(this.input, this.line)
|
||||||
|
this.message = mkMessage(err.message, this.token)
|
||||||
|
this.stack = context +
|
||||||
|
'\n' + (this.stack || this.message) +
|
||||||
|
(err.stack ? '\nFrom ' + err.stack : '')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class TokenizationError extends LiquidError {
|
||||||
|
constructor(message, token) {
|
||||||
|
super({message}, token)
|
||||||
|
super.captureStackTrace(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TokenizationError.prototype = _.create(Error.prototype)
|
||||||
|
TokenizationError.prototype.constructor = TokenizationError
|
||||||
|
|
||||||
|
export class ParseError extends LiquidError {
|
||||||
|
constructor(err, token) {
|
||||||
|
super(err, token)
|
||||||
|
_.assign(this, err)
|
||||||
|
super.captureStackTrace(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ParseError.prototype = _.create(Error.prototype)
|
||||||
|
ParseError.prototype.constructor = ParseError
|
||||||
|
|
||||||
|
export class RenderError extends LiquidError {
|
||||||
|
constructor(err, tpl) {
|
||||||
|
super(err, tpl.token)
|
||||||
|
_.assign(this, err)
|
||||||
|
super.captureStackTrace(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RenderError.prototype = _.create(Error.prototype)
|
||||||
|
RenderError.prototype.constructor = RenderError
|
||||||
|
|
||||||
|
export class RenderBreakError {
|
||||||
|
message: string
|
||||||
|
constructor (message) {
|
||||||
|
captureStack.call(this)
|
||||||
|
this.message = message + ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RenderBreakError.prototype = _.create(Error.prototype)
|
||||||
|
RenderBreakError.prototype.constructor = RenderBreakError
|
||||||
|
|
||||||
|
export class AssertionError {
|
||||||
|
message: string
|
||||||
|
constructor (message) {
|
||||||
|
captureStack.call(this)
|
||||||
|
this.message = message + ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AssertionError.prototype = _.create(Error.prototype)
|
||||||
|
AssertionError.prototype.constructor = AssertionError
|
||||||
|
|
||||||
|
function mkContext (input, targetLine) {
|
||||||
|
const lines = input.split('\n')
|
||||||
|
const begin = Math.max(targetLine - 2, 1)
|
||||||
|
const end = Math.min(targetLine + 3, lines.length)
|
||||||
|
|
||||||
|
const context = _
|
||||||
|
.range(begin, end + 1)
|
||||||
|
.map(lineNumber => {
|
||||||
|
const indicator = (lineNumber === targetLine) ? '>> ' : ' '
|
||||||
|
const num = padStart(String(end).length, lineNumber)
|
||||||
|
const text = lines[lineNumber - 1]
|
||||||
|
return `${indicator}${num}| ${text}`
|
||||||
|
})
|
||||||
|
.join('\n')
|
||||||
|
|
||||||
|
return context
|
||||||
|
}
|
||||||
|
|
||||||
|
function mkMessage (msg, token) {
|
||||||
|
msg = msg || ''
|
||||||
|
if (token.file) {
|
||||||
|
msg += ', file:' + token.file
|
||||||
|
}
|
||||||
|
if (token.line) {
|
||||||
|
msg += ', line:' + token.line
|
||||||
|
}
|
||||||
|
return msg
|
||||||
|
}
|
||||||
|
|
||||||
|
function padStart (length, str) {
|
||||||
|
str = String(str)
|
||||||
|
const blank = Array(length - str.length).join(' ')
|
||||||
|
return blank + str
|
||||||
|
}
|
||||||
@@ -15,9 +15,9 @@ export function isFunction (value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function promisify (fn) {
|
export function promisify (fn) {
|
||||||
return function () {
|
return function (...args) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
fn(...arguments, (err, result) => {
|
fn(...args, (err, result) => {
|
||||||
err ? reject(err) : resolve(result)
|
err ? reject(err) : resolve(result)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -96,11 +96,14 @@ export function forOwn (object, iteratee) {
|
|||||||
* @param {...Object} sources The source objects.
|
* @param {...Object} sources The source objects.
|
||||||
* @return {Object} Returns object.
|
* @return {Object} Returns object.
|
||||||
*/
|
*/
|
||||||
export function assign (object) {
|
export function assign (obj, ...srcs) {
|
||||||
object = isObject(object) ? object : {}
|
obj = isObject(obj) ? obj : {}
|
||||||
const srcs = Array.prototype.slice.call(arguments, 1)
|
srcs.forEach(src => binaryAssign(obj, src))
|
||||||
srcs.forEach((src) => Object.assign(object, src))
|
return obj
|
||||||
return object
|
}
|
||||||
|
|
||||||
|
function binaryAssign(target, src) {
|
||||||
|
for(let key in src) if (src.hasOwnProperty(key)) target[key] = src[key]
|
||||||
}
|
}
|
||||||
|
|
||||||
export function last (arr) {
|
export function last (arr) {
|
||||||
@@ -139,7 +142,7 @@ export function isObject (value) {
|
|||||||
* Note that ranges that stop before they start are considered to be zero-length instead of
|
* Note that ranges that stop before they start are considered to be zero-length instead of
|
||||||
* negative — if you'd like a negative range, use a negative step.
|
* negative — if you'd like a negative range, use a negative step.
|
||||||
*/
|
*/
|
||||||
export function range (start, stop, step) {
|
export function range (start: number, stop: number, step?: number) {
|
||||||
if (arguments.length === 1) {
|
if (arguments.length === 1) {
|
||||||
stop = start
|
stop = start
|
||||||
start = 0
|
start = 0
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { assign } from './util/underscore.js'
|
import { assign } from './util/underscore'
|
||||||
|
|
||||||
export default function whiteSpaceCtrl (tokens, options) {
|
export default function whiteSpaceCtrl (tokens, options) {
|
||||||
options = assign({ greedy: true }, options)
|
options = assign({ greedy: true }, options)
|
||||||
|
|||||||
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
--require babel-core/register
|
--require ts-node/register
|
||||||
--recursive
|
--recursive
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import sinon from 'sinon'
|
import * as sinon from 'sinon'
|
||||||
import sinonChai from 'sinon-chai'
|
import * as sinonChai from 'sinon-chai'
|
||||||
import Filter from '../../src/filter.js'
|
import Filter from '../../src/filter'
|
||||||
import { factory as scopeFactory } from '../../src/scope.js'
|
import { factory as scopeFactory } from '../../src/scope'
|
||||||
|
|
||||||
chai.use(sinonChai)
|
chai.use(sinonChai)
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import chaiAsPromised from 'chai-as-promised'
|
import * as chaiAsPromised from 'chai-as-promised'
|
||||||
import Liquid from '../../src/index'
|
import Liquid from '../../src/index'
|
||||||
|
|
||||||
chai.use(chaiAsPromised)
|
chai.use(chaiAsPromised)
|
||||||
@@ -130,7 +130,7 @@ describe('filters', function () {
|
|||||||
return test('{{ "Tetsuro Takara" | escape }}', 'Tetsuro Takara')
|
return test('{{ "Tetsuro Takara" | escape }}', 'Tetsuro Takara')
|
||||||
})
|
})
|
||||||
it('should escape function', function () {
|
it('should escape function', function () {
|
||||||
return test('{{ func | escape }}', 'function func() {}')
|
return test('{{ func | escape }}', 'function () { }')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
import Liquid from '../../src/index.js'
|
import Liquid from '../../src/index'
|
||||||
import mock from 'mock-fs'
|
import * as mock from 'mock-fs'
|
||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import mock from 'mock-fs'
|
import * as mock from 'mock-fs'
|
||||||
import Liquid from '../../../src'
|
import Liquid from '../../../src'
|
||||||
import chaiAsPromised from 'chai-as-promised'
|
import * as chaiAsPromised from 'chai-as-promised'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
chai.use(chaiAsPromised)
|
chai.use(chaiAsPromised)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Liquid from '../../../src'
|
import Liquid from '../../../src'
|
||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
chai.use(require('chai-as-promised'))
|
chai.use(require('chai-as-promised'))
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import Liquid from '../../../src'
|
import Liquid from '../../../src'
|
||||||
import chaiAsPromised from 'chai-as-promised'
|
import * as chaiAsPromised from 'chai-as-promised'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
chai.use(chaiAsPromised)
|
chai.use(chaiAsPromised)
|
||||||
|
|||||||
+5
-5
@@ -1,8 +1,8 @@
|
|||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import sinonChai from 'sinon-chai'
|
import * as sinonChai from 'sinon-chai'
|
||||||
import Filter from '../../src/filter.js'
|
import Filter from '../../src/filter'
|
||||||
import Tag from '../../src/tag.js'
|
import Tag from '../../src/tag'
|
||||||
import Template from '../../src/parser.js'
|
import Template from '../../src/parser'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
const filter = Filter()
|
const filter = Filter()
|
||||||
|
|||||||
+19
-19
@@ -1,12 +1,12 @@
|
|||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import chaiAsPromised from 'chai-as-promised'
|
import * as chaiAsPromised from 'chai-as-promised'
|
||||||
import sinonChai from 'sinon-chai'
|
import * as sinonChai from 'sinon-chai'
|
||||||
import sinon from 'sinon'
|
import * as sinon from 'sinon'
|
||||||
import Tag from '../../src/tag.js'
|
import Tag from '../../src/tag'
|
||||||
import { factory as scopeFactory } from '../../src/scope.js'
|
import Scope from '../../src/scope'
|
||||||
import Filter from '../../src/filter'
|
import Filter from '../../src/filter'
|
||||||
import Render from '../../src/render.js'
|
import Render from '../../src/render'
|
||||||
import parser from '../../src/parser.js'
|
import parser from '../../src/parser'
|
||||||
|
|
||||||
chai.use(sinonChai)
|
chai.use(sinonChai)
|
||||||
chai.use(chaiAsPromised)
|
chai.use(chaiAsPromised)
|
||||||
@@ -30,21 +30,21 @@ describe('render', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should render html', function () {
|
it('should render html', function () {
|
||||||
const scope = scopeFactory({})
|
const scope = new Scope()
|
||||||
return expect(render.renderTemplates([{ type: 'html', value: '<p>' }], scope)).to.eventually.equal('<p>')
|
return expect(render.renderTemplates([{ type: 'html', value: '<p>' }], scope)).to.eventually.equal('<p>')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('.renderValue()', function () {
|
describe('.renderValue()', function () {
|
||||||
it('should respect to .to_liquid() method', function () {
|
it('should respect to .to_liquid() method', function () {
|
||||||
const scope = scopeFactory({
|
const scope = new Scope({
|
||||||
bar: { to_liquid: x => 'custom' }
|
bar: { to_liquid: x => 'custom' }
|
||||||
})
|
})
|
||||||
const tpl = Template.parseValue('bar')
|
const tpl = Template.parseValue('bar')
|
||||||
return expect(render.renderValue(tpl, scope)).to.eventually.equal('custom')
|
return expect(render.renderValue(tpl, scope)).to.eventually.equal('custom')
|
||||||
})
|
})
|
||||||
it('should stringify objects', function () {
|
it('should stringify objects', function () {
|
||||||
const scope = scopeFactory({
|
const scope = new Scope({
|
||||||
foo: { obj: { arr: ['a', 2] } }
|
foo: { obj: { arr: ['a', 2] } }
|
||||||
})
|
})
|
||||||
const tpl = Template.parseValue('foo')
|
const tpl = Template.parseValue('foo')
|
||||||
@@ -54,29 +54,29 @@ describe('render', function () {
|
|||||||
const ctx = { foo: { num: 2 }, bar: 'bar' }
|
const ctx = { foo: { num: 2 }, bar: 'bar' }
|
||||||
ctx.foo.circular = ctx
|
ctx.foo.circular = ctx
|
||||||
|
|
||||||
const scope = scopeFactory(ctx)
|
const scope = new Scope(ctx)
|
||||||
const tpl = Template.parseValue('foo')
|
const tpl = Template.parseValue('foo')
|
||||||
return expect(render.renderValue(tpl, scope)).to.eventually.equal('{"num":2,"circular":{"bar":"bar"}}')
|
return expect(render.renderValue(tpl, scope)).to.eventually.equal('{"num":2,"circular":{"bar":"bar"}}')
|
||||||
})
|
})
|
||||||
it('should skip function property', function () {
|
it('should skip function property', function () {
|
||||||
const scope = scopeFactory({ obj: { foo: 'foo', bar: x => x } })
|
const scope = new Scope({ obj: { foo: 'foo', bar: x => x } })
|
||||||
const tpl = Template.parseValue('obj')
|
const tpl = Template.parseValue('obj')
|
||||||
return expect(render.renderValue(tpl, scope)).to.eventually.equal('{"foo":"foo"}')
|
return expect(render.renderValue(tpl, scope)).to.eventually.equal('{"foo":"foo"}')
|
||||||
})
|
})
|
||||||
it('should respect to .toString()', async () => {
|
it('should respect to .toString()', async () => {
|
||||||
const scope = scopeFactory({ obj: { toString: () => 'FOO' } })
|
const scope = new Scope({ obj: { toString: () => 'FOO' } })
|
||||||
const tpl = Template.parseValue('obj')
|
const tpl = Template.parseValue('obj')
|
||||||
const str = await render.renderValue(tpl, scope)
|
const str = await render.renderValue(tpl, scope)
|
||||||
return expect(str).to.equal('FOO')
|
return expect(str).to.equal('FOO')
|
||||||
})
|
})
|
||||||
it('should respect to .to_s()', async () => {
|
it('should respect to .to_s()', async () => {
|
||||||
const scope = scopeFactory({ obj: { to_s: () => 'FOO' } })
|
const scope = new Scope({ obj: { to_s: () => 'FOO' } })
|
||||||
const tpl = Template.parseValue('obj')
|
const tpl = Template.parseValue('obj')
|
||||||
const str = await render.renderValue(tpl, scope)
|
const str = await render.renderValue(tpl, scope)
|
||||||
return expect(str).to.equal('FOO')
|
return expect(str).to.equal('FOO')
|
||||||
})
|
})
|
||||||
it('should respect to .liquid_method_missing()', async () => {
|
it('should respect to .liquid_method_missing()', async () => {
|
||||||
const scope = scopeFactory({ obj: { liquid_method_missing: x => x.toUpperCase() } })
|
const scope = new Scope({ obj: { liquid_method_missing: x => x.toUpperCase() } })
|
||||||
const tpl = Template.parseValue('obj.foo')
|
const tpl = Template.parseValue('obj.foo')
|
||||||
const str = await render.renderValue(tpl, scope)
|
const str = await render.renderValue(tpl, scope)
|
||||||
return expect(str).to.equal('FOO')
|
return expect(str).to.equal('FOO')
|
||||||
@@ -93,7 +93,7 @@ describe('render', function () {
|
|||||||
filter.register('date', (l, r) => l + r)
|
filter.register('date', (l, r) => l + r)
|
||||||
filter.register('time', (l, r) => l + 3 * r)
|
filter.register('time', (l, r) => l + 3 * r)
|
||||||
const tpl = Template.parseValue('foo.bar[0] | date: "b" | time:2')
|
const tpl = Template.parseValue('foo.bar[0] | date: "b" | time:2')
|
||||||
const scope = scopeFactory({
|
const scope = new Scope({
|
||||||
foo: { bar: ['a'] }
|
foo: { bar: ['a'] }
|
||||||
})
|
})
|
||||||
expect(render.evalValue(tpl, scope)).to.equal('ab6')
|
expect(render.evalValue(tpl, scope)).to.equal('ab6')
|
||||||
@@ -101,7 +101,7 @@ describe('render', function () {
|
|||||||
it('should reserve type', function () {
|
it('should reserve type', function () {
|
||||||
filter.register('arr', () => [1])
|
filter.register('arr', () => [1])
|
||||||
const tpl = Template.parseValue('"x" | arr')
|
const tpl = Template.parseValue('"x" | arr')
|
||||||
expect(render.evalValue(tpl, scopeFactory())).to.deep.equal([1])
|
expect(render.evalValue(tpl, new Scope())).to.deep.equal([1])
|
||||||
})
|
})
|
||||||
it('should eval filter with correct arguments', function () {
|
it('should eval filter with correct arguments', function () {
|
||||||
const date = sinon.stub().returns('y')
|
const date = sinon.stub().returns('y')
|
||||||
@@ -109,7 +109,7 @@ describe('render', function () {
|
|||||||
filter.register('date', date)
|
filter.register('date', date)
|
||||||
filter.register('time', time)
|
filter.register('time', time)
|
||||||
const tpl = Template.parseValue('foo.bar | date: "b" | time:2')
|
const tpl = Template.parseValue('foo.bar | date: "b" | time:2')
|
||||||
const scope = scopeFactory({
|
const scope = new Scope({
|
||||||
foo: { bar: 'bar' }
|
foo: { bar: 'bar' }
|
||||||
})
|
})
|
||||||
render.evalValue(tpl, scope)
|
render.evalValue(tpl, scope)
|
||||||
|
|||||||
+6
-6
@@ -1,5 +1,5 @@
|
|||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import { factory as scopeFactory } from '../../src/scope.js'
|
import Scope from '../../src/scope'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ describe('scope', function () {
|
|||||||
arr: ['a', 'b']
|
arr: ['a', 'b']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scope = scopeFactory(ctx)
|
scope = new Scope(ctx)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#propertyAccessSeq()', function () {
|
describe('#propertyAccessSeq()', function () {
|
||||||
@@ -97,7 +97,7 @@ describe('scope', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should respect to to_liquid', function () {
|
it('should respect to to_liquid', function () {
|
||||||
const scope = scopeFactory({ foo: {
|
const scope = new Scope({ foo: {
|
||||||
to_liquid: () => ({ bar: 'BAR' }),
|
to_liquid: () => ({ bar: 'BAR' }),
|
||||||
bar: 'bar'
|
bar: 'bar'
|
||||||
} })
|
} })
|
||||||
@@ -105,7 +105,7 @@ describe('scope', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should respect to toLiquid', function () {
|
it('should respect to toLiquid', function () {
|
||||||
const scope = scopeFactory({ foo: {
|
const scope = new Scope({ foo: {
|
||||||
toLiquid: () => ({ bar: 'BAR' }),
|
toLiquid: () => ({ bar: 'BAR' }),
|
||||||
bar: 'bar'
|
bar: 'bar'
|
||||||
} })
|
} })
|
||||||
@@ -171,7 +171,7 @@ describe('scope', function () {
|
|||||||
describe('strict_variables', function () {
|
describe('strict_variables', function () {
|
||||||
let scope
|
let scope
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
scope = scopeFactory(ctx, {
|
scope = new Scope(ctx, {
|
||||||
strict_variables: true
|
strict_variables: true
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
+4
-9
@@ -1,17 +1,12 @@
|
|||||||
const chai = require('chai')
|
import Scope from '../../src/scope'
|
||||||
const expect = chai.expect
|
import { expect } from 'chai'
|
||||||
const syntax = require('../../src/syntax.js')
|
import { evalExp, evalValue, isTruthy } from '../../src/syntax'
|
||||||
const Scope = require('../../src/scope.js')
|
|
||||||
|
|
||||||
const evalExp = syntax.evalExp
|
|
||||||
const evalValue = syntax.evalValue
|
|
||||||
const isTruthy = syntax.isTruthy
|
|
||||||
|
|
||||||
describe('expression', function () {
|
describe('expression', function () {
|
||||||
let scope
|
let scope
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
scope = Scope.factory({
|
scope = new Scope({
|
||||||
one: 1,
|
one: 1,
|
||||||
two: 2,
|
two: 2,
|
||||||
empty: '',
|
empty: '',
|
||||||
|
|||||||
+6
-6
@@ -1,8 +1,8 @@
|
|||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import Tag from '../../src/tag.js'
|
import Tag from '../../src/tag'
|
||||||
import { factory as scopeFactory } from '../../src/scope.js'
|
import Scope from '../../src/scope'
|
||||||
import sinon from 'sinon'
|
import * as sinon from 'sinon'
|
||||||
import sinonChai from 'sinon-chai'
|
import * as sinonChai from 'sinon-chai'
|
||||||
|
|
||||||
chai.use(sinonChai)
|
chai.use(sinonChai)
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
@@ -11,7 +11,7 @@ const tag = Tag()
|
|||||||
describe('tag', function () {
|
describe('tag', function () {
|
||||||
let scope
|
let scope
|
||||||
before(function () {
|
before(function () {
|
||||||
scope = scopeFactory({
|
scope = new Scope({
|
||||||
foo: 'bar',
|
foo: 'bar',
|
||||||
arr: [2, 1],
|
arr: [2, 1],
|
||||||
bar: {
|
bar: {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import Liquid from '../../../src'
|
import Liquid from '../../../src'
|
||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import sinonChai from 'chai-as-promised'
|
import * as sinonChai from 'chai-as-promised'
|
||||||
|
|
||||||
chai.use(sinonChai)
|
chai.use(sinonChai)
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Liquid from '../../../src/index'
|
import Liquid from '../../../src/index'
|
||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
chai.use(require('chai-as-promised'))
|
chai.use(require('chai-as-promised'))
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Liquid from '../../../src'
|
import Liquid from '../../../src'
|
||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
chai.use(require('chai-as-promised'))
|
chai.use(require('chai-as-promised'))
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Liquid from '../../../src'
|
import Liquid from '../../../src'
|
||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
chai.use(require('chai-as-promised'))
|
chai.use(require('chai-as-promised'))
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Liquid from '../../../src'
|
import Liquid from '../../../src'
|
||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
chai.use(require('chai-as-promised'))
|
chai.use(require('chai-as-promised'))
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Liquid from '../../../src'
|
import Liquid from '../../../src'
|
||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
chai.use(require('chai-as-promised'))
|
chai.use(require('chai-as-promised'))
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Liquid from '../../../src'
|
import Liquid from '../../../src'
|
||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
chai.use(require('chai-as-promised'))
|
chai.use(require('chai-as-promised'))
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Liquid from '../../../src/index'
|
import Liquid from '../../../src/index'
|
||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
chai.use(require('chai-as-promised'))
|
chai.use(require('chai-as-promised'))
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import Liquid from '../../../src'
|
import Liquid from '../../../src'
|
||||||
import mock from 'mock-fs'
|
import * as mock from 'mock-fs'
|
||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
chai.use(require('chai-as-promised'))
|
chai.use(require('chai-as-promised'))
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Liquid from '../../../src'
|
import Liquid from '../../../src'
|
||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
chai.use(require('chai-as-promised'))
|
chai.use(require('chai-as-promised'))
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import Liquid from '../../../src'
|
import Liquid from '../../../src'
|
||||||
import mock from 'mock-fs'
|
import * as mock from 'mock-fs'
|
||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
chai.use(require('chai-as-promised'))
|
chai.use(require('chai-as-promised'))
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Liquid from '../../../src'
|
import Liquid from '../../../src'
|
||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
chai.use(require('chai-as-promised'))
|
chai.use(require('chai-as-promised'))
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Liquid from '../../../src'
|
import Liquid from '../../../src'
|
||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
chai.use(require('chai-as-promised'))
|
chai.use(require('chai-as-promised'))
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Liquid from '../../../src'
|
import Liquid from '../../../src'
|
||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
chai.use(require('chai-as-promised'))
|
chai.use(require('chai-as-promised'))
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { resolve } from '../../src/template-browser.js'
|
import { resolve } from '../../src/template-browser'
|
||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { resolve } from '../../src/template.js'
|
import { resolve } from '../../src/template'
|
||||||
import mock from 'mock-fs'
|
import * as mock from 'mock-fs'
|
||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import path from 'path'
|
import * as path from 'path'
|
||||||
import chaiAsPromised from 'chai-as-promised'
|
import * as chaiAsPromised from 'chai-as-promised'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
chai.use(chaiAsPromised)
|
chai.use(chaiAsPromised)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import assert from '../../../src/util/assert.js'
|
import assert from '../../../src/util/assert'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import Liquid from '../../../src'
|
import Liquid from '../../../src'
|
||||||
import mock from 'mock-fs'
|
import * as mock from 'mock-fs'
|
||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import path from 'path'
|
import * as path from 'path'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
chai.use(require('chai-as-promised'))
|
chai.use(require('chai-as-promised'))
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import t from '../../../src/util/strftime.js'
|
import t from '../../../src/util/strftime'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import sinonChai from 'sinon-chai'
|
import * as sinonChai from 'sinon-chai'
|
||||||
import sinon from 'sinon'
|
import * as sinon from 'sinon'
|
||||||
import { RenderError, RenderBreakError } from '../../../src/util/error.js'
|
import { RenderError, RenderBreakError } from '../../../src/util/error'
|
||||||
import * as _ from '../../../src/util/underscore.js'
|
import * as _ from '../../../src/util/underscore'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
chai.use(sinonChai)
|
chai.use(sinonChai)
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
import { read } from '../../src/template-browser.js'
|
import { read } from '../../src/template-browser'
|
||||||
import sinon from 'sinon'
|
import * as sinon from 'sinon'
|
||||||
import chai from 'chai'
|
import * as chai from 'chai'
|
||||||
|
|
||||||
chai.use(require('chai-as-promised'))
|
chai.use(require('chai-as-promised'))
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es5",
|
||||||
|
"module":"CommonJS",
|
||||||
|
"lib": ["es2015", "es2016", "es2017", "dom"],
|
||||||
|
"allowJs": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"emitDecoratorMetadata": true
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src"
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user