mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 12:50:38 -07:00
fix: break/continue omitting output before them, #123
BREAKING CHANGE: remove default export, now should be used like import
{Liquid} from 'liquidjs'
This commit is contained in:
+3
-5
@@ -1,7 +1,5 @@
|
||||
import * as Benchmark from 'benchmark'
|
||||
import Liquid from '../src/liquid'
|
||||
import TagToken from '../src/parser/tag-token'
|
||||
import Context from '../src/context/context'
|
||||
import { Context, TagToken, Liquid } from '../src/liquid'
|
||||
|
||||
const engine = new Liquid({
|
||||
root: __dirname,
|
||||
@@ -34,13 +32,13 @@ const template = `
|
||||
</ul>
|
||||
`
|
||||
|
||||
export default function () {
|
||||
export function demo () {
|
||||
console.log('--- demo ---')
|
||||
return new Promise(resolve => {
|
||||
new Benchmark.Suite('demo')
|
||||
.add('demo', {
|
||||
defer: true,
|
||||
fn: (d: any) => engine.parseAndRender(template, ctx).then(x => d.resolve(x))
|
||||
fn: (d: any) => engine.parseAndRender(template, ctx).then((x: any) => d.resolve(x))
|
||||
})
|
||||
.on('cycle', (event: any) => console.log(String(event.target)))
|
||||
.on('complete', resolve)
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
import output from './output'
|
||||
import tag from './tag'
|
||||
import demo from './demo'
|
||||
import layout from './layout'
|
||||
import { output } from './output'
|
||||
import { tag } from './tag'
|
||||
import { demo } from './demo'
|
||||
import { layout } from './layout'
|
||||
|
||||
async function main () {
|
||||
await output()
|
||||
|
||||
+3
-3
@@ -17,17 +17,17 @@ const template = `
|
||||
{% block body %}a small body{% endblock %}
|
||||
`
|
||||
|
||||
export default function () {
|
||||
export function layout () {
|
||||
console.log('--- layout ---')
|
||||
return new Promise(resolve => {
|
||||
new Benchmark.Suite('layout')
|
||||
.add('cache=false', {
|
||||
defer: true,
|
||||
fn: (d: any) => engine.parseAndRender(template, {}).then(x => d.resolve(x))
|
||||
fn: (d: any) => engine.parseAndRender(template, {}).then((x: any) => d.resolve(x))
|
||||
})
|
||||
.add('cache=true', {
|
||||
defer: true,
|
||||
fn: (d: any) => cachingEngine.parseAndRender(template, {}).then(x => d.resolve(x))
|
||||
fn: (d: any) => cachingEngine.parseAndRender(template, {}).then((x: any) => d.resolve(x))
|
||||
})
|
||||
.on('cycle', (event: any) => console.log(String(event.target)))
|
||||
.on('complete', resolve)
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@ import Liquid from '../src/liquid'
|
||||
|
||||
const liquid = new Liquid()
|
||||
|
||||
export default function () {
|
||||
export function output () {
|
||||
console.log('--- output ---')
|
||||
return new Promise(resolve => {
|
||||
new Benchmark.Suite('output')
|
||||
@@ -21,6 +21,6 @@ export default function () {
|
||||
function test (str: string) {
|
||||
return {
|
||||
defer: true,
|
||||
fn: (d: any) => liquid.parseAndRender(str).then(x => d.resolve(x))
|
||||
fn: (d: any) => liquid.parseAndRender(str).then((x: any) => d.resolve(x))
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@ import Liquid from '../src/liquid'
|
||||
|
||||
const liquid = new Liquid()
|
||||
|
||||
export default function () {
|
||||
export function tag () {
|
||||
console.log('--- tag ---')
|
||||
return new Promise(resolve => {
|
||||
new Benchmark.Suite('tag')
|
||||
@@ -25,6 +25,6 @@ export default function () {
|
||||
function test (str: string) {
|
||||
return {
|
||||
defer: true,
|
||||
fn: (d: any) => liquid.parseAndRender(str).then(x => d.resolve(x))
|
||||
fn: (d: any) => liquid.parseAndRender(str).then((x: any) => d.resolve(x))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user