mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 21:00:40 -07:00
feat: renderSync, parseAndRenderSync and renderFileSync, see #48
This commit is contained in:
+12
-4
@@ -5,11 +5,15 @@ import { parseLiteral } from '../parser/literal'
|
||||
export class Value {
|
||||
private str: string
|
||||
|
||||
public constructor (str: string = '') {
|
||||
public constructor (str: string) {
|
||||
this.str = str
|
||||
}
|
||||
|
||||
public evaluate (ctx: Context) {
|
||||
public async evaluate (ctx: Context) {
|
||||
return this.evaluateSync(ctx)
|
||||
}
|
||||
|
||||
public evaluateSync (ctx: Context) {
|
||||
const literalValue = parseLiteral(this.str)
|
||||
if (literalValue !== undefined) {
|
||||
return literalValue
|
||||
@@ -17,7 +21,11 @@ export class Value {
|
||||
return ctx.get(this.str)
|
||||
}
|
||||
|
||||
public value (ctx: Context) {
|
||||
return toValue(this.evaluate(ctx))
|
||||
public async value (ctx: Context) {
|
||||
return toValue(await this.evaluate(ctx))
|
||||
}
|
||||
|
||||
public valueSync (ctx: Context) {
|
||||
return toValue(this.evaluateSync(ctx))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user