Skip to content

Commit ae45c46

Browse files
committed
fix: break/continue omitting output before them, #123
BREAKING CHANGE: remove default export, now should be used like import {Liquid} from 'liquidjs'
1 parent 854e12b commit ae45c46

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+373
-407
lines changed

benchmark/demo.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import * as Benchmark from 'benchmark'
2-
import Liquid from '../src/liquid'
3-
import TagToken from '../src/parser/tag-token'
4-
import Context from '../src/context/context'
2+
import { Context, TagToken, Liquid } from '../src/liquid'
53

64
const engine = new Liquid({
75
root: __dirname,
@@ -34,13 +32,13 @@ const template = `
3432
</ul>
3533
`
3634

37-
export default function () {
35+
export function demo () {
3836
console.log('--- demo ---')
3937
return new Promise(resolve => {
4038
new Benchmark.Suite('demo')
4139
.add('demo', {
4240
defer: true,
43-
fn: (d: any) => engine.parseAndRender(template, ctx).then(x => d.resolve(x))
41+
fn: (d: any) => engine.parseAndRender(template, ctx).then((x: any) => d.resolve(x))
4442
})
4543
.on('cycle', (event: any) => console.log(String(event.target)))
4644
.on('complete', resolve)

benchmark/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import output from './output'
2-
import tag from './tag'
3-
import demo from './demo'
4-
import layout from './layout'
1+
import { output } from './output'
2+
import { tag } from './tag'
3+
import { demo } from './demo'
4+
import { layout } from './layout'
55

66
async function main () {
77
await output()

benchmark/layout.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ const template = `
1717
{% block body %}a small body{% endblock %}
1818
`
1919

20-
export default function () {
20+
export function layout () {
2121
console.log('--- layout ---')
2222
return new Promise(resolve => {
2323
new Benchmark.Suite('layout')
2424
.add('cache=false', {
2525
defer: true,
26-
fn: (d: any) => engine.parseAndRender(template, {}).then(x => d.resolve(x))
26+
fn: (d: any) => engine.parseAndRender(template, {}).then((x: any) => d.resolve(x))
2727
})
2828
.add('cache=true', {
2929
defer: true,
30-
fn: (d: any) => cachingEngine.parseAndRender(template, {}).then(x => d.resolve(x))
30+
fn: (d: any) => cachingEngine.parseAndRender(template, {}).then((x: any) => d.resolve(x))
3131
})
3232
.on('cycle', (event: any) => console.log(String(event.target)))
3333
.on('complete', resolve)

benchmark/output.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Liquid from '../src/liquid'
33

44
const liquid = new Liquid()
55

6-
export default function () {
6+
export function output () {
77
console.log('--- output ---')
88
return new Promise(resolve => {
99
new Benchmark.Suite('output')
@@ -21,6 +21,6 @@ export default function () {
2121
function test (str: string) {
2222
return {
2323
defer: true,
24-
fn: (d: any) => liquid.parseAndRender(str).then(x => d.resolve(x))
24+
fn: (d: any) => liquid.parseAndRender(str).then((x: any) => d.resolve(x))
2525
}
2626
}

benchmark/tag.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Liquid from '../src/liquid'
33

44
const liquid = new Liquid()
55

6-
export default function () {
6+
export function tag () {
77
console.log('--- tag ---')
88
return new Promise(resolve => {
99
new Benchmark.Suite('tag')
@@ -25,6 +25,6 @@ export default function () {
2525
function test (str: string) {
2626
return {
2727
defer: true,
28-
fn: (d: any) => liquid.parseAndRender(str).then(x => d.resolve(x))
28+
fn: (d: any) => liquid.parseAndRender(str).then((x: any) => d.resolve(x))
2929
}
3030
}

demo/browser/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
<body>
1010
<script>
11-
var engine = new window.Liquid({
11+
var Liquid = window.liquidjs.Liquid
12+
var engine = new Liquid({
1213
extname: '.html',
1314
cache: true
1415
});

demo/express/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const express = require('express')
2-
const Liquid = require('../..')
2+
const { Liquid } = require('liquidjs')
33

44
const app = express()
55
const engine = new Liquid({

demo/nodejs/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const Liquid = require('liquidjs')
1+
const { Liquid } = require('liquidjs')
22

33
const engine = new Liquid({
44
root: __dirname,

demo/typescript/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import Liquid from 'liquidjs'
1+
import { Liquid, TagToken, Hash, Context } from 'liquidjs'
22

33
const engine = new Liquid({
44
root: __dirname,
55
extname: '.liquid'
66
})
77

88
engine.registerTag('header', {
9-
parse: function (token) {
9+
parse: function (token: TagToken) {
1010
const [key, val] = token.args.split(':')
1111
this[key] = val
1212
},
13-
render: function (scope, hash) {
14-
const title = this.liquid.evalValue(this['content'], scope)
13+
render: function (context: Context, hash: Hash) {
14+
const title = this.liquid.evalValue(this['content'], context)
1515
return `<h1>${title}</h1>`
1616
}
1717
})

rollup.config.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const input = './src/liquid.ts'
1818
const cjs = {
1919
output: [{
2020
file: 'dist/liquid.common.js',
21-
name: 'Liquid',
2221
format: 'cjs',
2322
sourcemap,
2423
banner
@@ -41,7 +40,7 @@ const cjs = {
4140
const umd = {
4241
output: [{
4342
file: 'dist/liquid.js',
44-
name: 'Liquid',
43+
name: 'liquidjs',
4544
format: 'umd',
4645
sourcemap,
4746
banner
@@ -70,7 +69,7 @@ const umd = {
7069
const min = {
7170
output: [{
7271
file: 'dist/liquid.min.js',
73-
name: 'Liquid',
72+
name: 'liquidjs',
7473
format: 'umd',
7574
sourcemap
7675
}],

0 commit comments

Comments
 (0)