Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev 9.0.0 #156

Merged
merged 12 commits into from
Aug 26, 2019
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"prefer-const": 2,
"no-unused-vars": "off",
"indent": "off",
"no-dupe-class-members": "off",
"@typescript-eslint/indent": ["error", 2],
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off",
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ coverage/
# modules
node_modules/
dist/
demo/*/package-lock.json
demo/*/yarn.json

# editors
.*.swp
.vscode

4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ A [shopify][shopify/liquid] compatible [Liquid][tutorial] template engine in pur
All features, filters and tags in [shopify/liquid](https://github.com/Shopify/liquid) are supposed to be built in LiquidJS,
though there are still some differences and limitations (see below).

[Donate to our collective](https://opencollective.com/liquidjs/donate) if you like liquidjs.

## Get Started

Install via npm:
Expand All @@ -30,7 +28,7 @@ npm install --save liquidjs
```

```javascript
var Liquid = require('liquidjs');
var { Liquid } = require('liquidjs');
var engine = new Liquid();

engine
Expand Down
8 changes: 3 additions & 5 deletions benchmark/demo.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions benchmark/index.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
8 changes: 4 additions & 4 deletions benchmark/layout.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Benchmark from 'benchmark'
import Liquid from '../src/liquid'
import { Liquid } from '../src/liquid'

const engineOptions = {
root: __dirname,
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions benchmark/output.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as Benchmark from 'benchmark'
import Liquid from '../src/liquid'
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')
Expand All @@ -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))
}
}
6 changes: 3 additions & 3 deletions benchmark/tag.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as Benchmark from 'benchmark'
import Liquid from '../src/liquid'
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')
Expand All @@ -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))
}
}
3 changes: 2 additions & 1 deletion demo/browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

<body>
<script>
var engine = new window.Liquid({
var Liquid = window.liquidjs.Liquid
var engine = new Liquid({
extname: '.html',
cache: true
});
Expand Down
220 changes: 0 additions & 220 deletions demo/browser/package-lock.json

This file was deleted.

6 changes: 2 additions & 4 deletions demo/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
},
"author": "harttle <yangjvn@126.com>",
"license": "ISC",
"devDependencies": {
"http-server": "^0.11.1"
},
"dependencies": {
"liquidjs": "^7.0.0"
"http-server": "^0.11.1",
"liquidjs": "*"
}
}
2 changes: 1 addition & 1 deletion demo/express/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const express = require('express')
const Liquid = require('../..')
const { Liquid } = require('liquidjs')

const app = express()
const engine = new Liquid({
Expand Down