mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-18 22:10:41 -07:00
chore: fix linting
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import FilterImpl from "src/template/filter/filter-impl";
|
||||
import { FilterImpl } from 'src/template/filter/filter-impl'
|
||||
|
||||
export default {
|
||||
'append': (v: string, arg: string) => v + arg,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default {
|
||||
'url_decode': (x: string) => x.split('+').map(decodeURIComponent).join(' '),
|
||||
'url_encode': (x: string) => x.split(' ').map(encodeURIComponent).join('+')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import assert from 'src/util/assert'
|
||||
import { identifier } from 'src/parser/lexical'
|
||||
import { AssignScope } from 'src/scope/scopes'
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Scope from 'src/scope/scope';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Scope from 'src/scope/scope'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
|
||||
const re = new RegExp(`(${identifier.source})\\s*=([^]*)`)
|
||||
|
||||
@@ -20,4 +20,4 @@ export default {
|
||||
scope.push(ctx)
|
||||
return Promise.resolve('')
|
||||
}
|
||||
} as ITagImplOptions
|
||||
} as ITagImplOptions
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import BlockMode from 'src/scope/block-mode'
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Token from 'src/parser/token';
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Token from 'src/parser/token'
|
||||
import ITemplate from 'src/template/itemplate'
|
||||
import Scope from 'src/scope/scope';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import ParseStream from 'src/parser/parse-stream';
|
||||
import Scope from 'src/scope/scope'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
import ParseStream from 'src/parser/parse-stream'
|
||||
|
||||
export default {
|
||||
parse: function (token: TagToken, remainTokens: Token[]) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { CaptureScope } from 'src/scope/scopes'
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Token from 'src/parser/token'
|
||||
import Scope from 'src/scope/scope'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
|
||||
const re = new RegExp(`(${identifier.source})`)
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { evalExp } from 'src/render/syntax'
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Token from 'src/parser/token';
|
||||
import Scope from 'src/scope/scope';
|
||||
import ITemplate from 'src/template/itemplate';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import ParseStream from 'src/parser/parse-stream';
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Token from 'src/parser/token'
|
||||
import Scope from 'src/scope/scope'
|
||||
import ITemplate from 'src/template/itemplate'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
import ParseStream from 'src/parser/parse-stream'
|
||||
|
||||
export default {
|
||||
parse: function (tagToken: TagToken, remainTokens: Token[]) {
|
||||
@@ -41,4 +41,4 @@ export default {
|
||||
}
|
||||
return this.liquid.renderer.renderTemplates(this.elseTemplates, scope)
|
||||
}
|
||||
} as ITagImplOptions
|
||||
} as ITagImplOptions
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import TagToken from "src/parser/tag-token";
|
||||
import Token from "src/parser/token";
|
||||
import ITagImplOptions from "src/template/tag/itag-impl-options";
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Token from 'src/parser/token'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
|
||||
export default {
|
||||
parse: function (tagToken: TagToken, remainTokens: Token[]) {
|
||||
@@ -14,4 +14,4 @@ export default {
|
||||
})
|
||||
stream.start()
|
||||
}
|
||||
} as ITagImplOptions
|
||||
} as ITagImplOptions
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import assert from 'src/util/assert'
|
||||
import { value as rValue } from 'src/parser/lexical'
|
||||
import { evalValue } from 'src/render/syntax'
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Scope from 'src/scope/scope';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Scope from 'src/scope/scope'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
|
||||
const groupRE = new RegExp(`^(?:(${rValue.source})\\s*:\\s*)?(.*)$`)
|
||||
const candidatesRE = new RegExp(rValue.source, 'g')
|
||||
@@ -40,4 +40,4 @@ export default <ITagImplOptions>{
|
||||
|
||||
return evalValue(candidate, scope)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { identifier } from 'src/parser/lexical'
|
||||
import { CaptureScope, AssignScope, DecrementScope } from 'src/scope/scopes'
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Scope from 'src/scope/scope'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
|
||||
export default {
|
||||
parse: function (token: TagToken) {
|
||||
@@ -27,4 +27,4 @@ export default {
|
||||
}
|
||||
return --context[this.variable]
|
||||
}
|
||||
} as ITagImplOptions
|
||||
} as ITagImplOptions
|
||||
|
||||
+17
-17
@@ -3,13 +3,13 @@ import { isString, isObject, isArray } from 'src/util/underscore'
|
||||
import { evalExp } from 'src/render/syntax'
|
||||
import assert from 'src/util/assert'
|
||||
import { identifier, value, hash } from 'src/parser/lexical'
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Token from 'src/parser/token';
|
||||
import Scope from 'src/scope/scope';
|
||||
import Hash from 'src/template/tag/hash';
|
||||
import ITemplate from 'src/template/itemplate';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import ParseStream from 'src/parser/parse-stream';
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Token from 'src/parser/token'
|
||||
import Scope from 'src/scope/scope'
|
||||
import Hash from 'src/template/tag/hash'
|
||||
import ITemplate from 'src/template/itemplate'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
import ParseStream from 'src/parser/parse-stream'
|
||||
|
||||
const re = new RegExp(`^(${identifier.source})\\s+in\\s+` +
|
||||
`(${value.source})` +
|
||||
@@ -25,10 +25,10 @@ export default <ITagImplOptions>{
|
||||
this.variable = match[1]
|
||||
this.collection = match[2]
|
||||
this.reversed = !!match[3]
|
||||
|
||||
|
||||
this.templates = []
|
||||
this.elseTemplates = []
|
||||
|
||||
|
||||
let p
|
||||
const stream: ParseStream = this.liquid.parser.parseStream(remainTokens)
|
||||
.on('start', () => (p = this.templates))
|
||||
@@ -38,12 +38,12 @@ export default <ITagImplOptions>{
|
||||
.on('end', () => {
|
||||
throw new Error(`tag ${tagToken.raw} not closed`)
|
||||
})
|
||||
|
||||
|
||||
stream.start()
|
||||
},
|
||||
render: async function (scope: Scope, hash: Hash) {
|
||||
let collection = evalExp(this.collection, scope)
|
||||
|
||||
|
||||
if (!isArray(collection)) {
|
||||
if (isString(collection) && collection.length > 0) {
|
||||
collection = [collection] as string[]
|
||||
@@ -54,13 +54,13 @@ export default <ITagImplOptions>{
|
||||
if (!isArray(collection) || !collection.length) {
|
||||
return this.liquid.renderer.renderTemplates(this.elseTemplates, scope)
|
||||
}
|
||||
|
||||
|
||||
const offset = hash.offset || 0
|
||||
const limit = (hash.limit === undefined) ? collection.length : hash.limit
|
||||
|
||||
|
||||
collection = collection.slice(offset, offset + limit)
|
||||
if (this.reversed) collection.reverse()
|
||||
|
||||
|
||||
const contexts = collection.map((item: string, i: number) => {
|
||||
const ctx = {}
|
||||
ctx[this.variable] = item
|
||||
@@ -75,12 +75,12 @@ export default <ITagImplOptions>{
|
||||
}
|
||||
return ctx
|
||||
})
|
||||
|
||||
|
||||
let html = ''
|
||||
let finished = false
|
||||
await mapSeries(contexts, async context => {
|
||||
if (finished) return
|
||||
|
||||
|
||||
scope.push(context)
|
||||
try {
|
||||
html += await this.liquid.renderer.renderTemplates(this.templates, scope)
|
||||
@@ -96,4 +96,4 @@ export default <ITagImplOptions>{
|
||||
})
|
||||
return html
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { evalExp, isTruthy } from 'src/render/syntax'
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Token from 'src/parser/token';
|
||||
import Scope from 'src/scope/scope';
|
||||
import ITemplate from 'src/template/itemplate';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import ParseStream from 'src/parser/parse-stream';
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Token from 'src/parser/token'
|
||||
import Scope from 'src/scope/scope'
|
||||
import ITemplate from 'src/template/itemplate'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
import ParseStream from 'src/parser/parse-stream'
|
||||
|
||||
export default {
|
||||
parse: function (tagToken: TagToken, remainTokens: Token[]) {
|
||||
|
||||
@@ -2,10 +2,10 @@ import assert from 'src/util/assert'
|
||||
import { value, quotedLine } from 'src/parser/lexical'
|
||||
import { evalValue } from 'src/render/syntax'
|
||||
import BlockMode from 'src/scope/block-mode'
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Scope from 'src/scope/scope';
|
||||
import Hash from 'src/template/tag/hash';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Scope from 'src/scope/scope'
|
||||
import Hash from 'src/template/tag/hash'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
|
||||
const staticFileRE = /[^\s,]+/
|
||||
const withRE = new RegExp(`with\\s+(${value.source})`)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import assert from 'src/util/assert'
|
||||
import { identifier } from 'src/parser/lexical'
|
||||
import { CaptureScope, AssignScope, IncrementScope } from 'src/scope/scopes'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
|
||||
export default {
|
||||
parse: function (token) {
|
||||
@@ -27,4 +27,4 @@ export default {
|
||||
context[this.variable]++
|
||||
return val
|
||||
}
|
||||
} as ITagImplOptions
|
||||
} as ITagImplOptions
|
||||
|
||||
@@ -2,11 +2,11 @@ import assert from 'src/util/assert'
|
||||
import { value as rValue } from 'src/parser/lexical'
|
||||
import { evalValue } from 'src/render/syntax'
|
||||
import BlockMode from 'src/scope/block-mode'
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Token from 'src/parser/token';
|
||||
import Scope from 'src/scope/scope';
|
||||
import Hash from 'src/template/tag/hash';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Token from 'src/parser/token'
|
||||
import Scope from 'src/scope/scope'
|
||||
import Hash from 'src/template/tag/hash'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
|
||||
const staticFileRE = /\S+/
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import TagToken from "src/parser/tag-token";
|
||||
import Token from "src/parser/token";
|
||||
import ITagImplOptions from "src/template/tag/itag-impl-options";
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Token from 'src/parser/token'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
|
||||
export default <ITagImplOptions>{
|
||||
parse: function (tagToken: TagToken, remainTokens: Token[]) {
|
||||
|
||||
@@ -2,13 +2,13 @@ import { mapSeries } from 'src/util/promise'
|
||||
import assert from 'src/util/assert'
|
||||
import { evalExp } from 'src/render/syntax'
|
||||
import { identifier, value, hash } from 'src/parser/lexical'
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Token from 'src/parser/token';
|
||||
import ITemplate from 'src/template/itemplate';
|
||||
import Scope from 'src/scope/scope';
|
||||
import Hash from 'src/template/tag/hash';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import ParseStream from 'src/parser/parse-stream';
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Token from 'src/parser/token'
|
||||
import ITemplate from 'src/template/itemplate'
|
||||
import Scope from 'src/scope/scope'
|
||||
import Hash from 'src/template/tag/hash'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
import ParseStream from 'src/parser/parse-stream'
|
||||
|
||||
const re = new RegExp(`^(${identifier.source})\\s+in\\s+` +
|
||||
`(${value.source})` +
|
||||
@@ -72,4 +72,4 @@ export default {
|
||||
}
|
||||
return html
|
||||
}
|
||||
} as ITagImplOptions
|
||||
} as ITagImplOptions
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { evalExp, isFalsy } from 'src/render/syntax'
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Token from 'src/parser/token';
|
||||
import ITemplate from 'src/template/itemplate';
|
||||
import Scope from 'src/scope/scope';
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
import ParseStream from 'src/parser/parse-stream';
|
||||
import TagToken from 'src/parser/tag-token'
|
||||
import Token from 'src/parser/token'
|
||||
import Scope from 'src/scope/scope'
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options'
|
||||
import ParseStream from 'src/parser/parse-stream'
|
||||
|
||||
export default {
|
||||
parse: function (tagToken: TagToken, remainTokens: Token[]) {
|
||||
@@ -32,4 +31,4 @@ export default {
|
||||
? this.liquid.renderer.renderTemplates(this.templates, scope)
|
||||
: this.liquid.renderer.renderTemplates(this.elseTemplates, scope)
|
||||
}
|
||||
} as ITagImplOptions
|
||||
} as ITagImplOptions
|
||||
|
||||
Reference in New Issue
Block a user