Files
liquidjs/benchmark/engines/liquid.js
T
harttle 24f5346084 perf: improve performance by 4x by simplified parseFile
- previously deprecated `getTemplate()` and `getTemplateSync()` not no longer supported
- `opts` no longer support dynamic set in `parseFile()`, `renderFile()` arguments
2021-09-27 23:04:41 +08:00

17 lines
430 B
JavaScript

const { Liquid } = require('../..')
const { readFileSync } = require('fs')
const { join } = require('path')
const liquid = new Liquid({
root: join(__dirname, '../templates'),
cache: true,
extname: '.liquid'
})
liquid.registerFilter('url', path => `http://example.com${path}`)
module.exports = {
load: path => liquid.parse(readFileSync(path + '.liquid', 'utf8')),
render: (tpl, data) => liquid.renderSync(tpl, data)
}