mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
BREAKING CHANGE: remove default export, now should be used like import
{Liquid} from 'liquidjs'
33 lines
708 B
HTML
33 lines
708 B
HTML
<!DOCTYPE html>
|
|
<html>
|
|
|
|
<head>
|
|
<title>liquidjs for the browser</title>
|
|
<script src="node_modules/liquidjs/dist/liquid.min.js"></script>
|
|
</head>
|
|
|
|
<body>
|
|
<script>
|
|
var Liquid = window.liquidjs.Liquid
|
|
var engine = new Liquid({
|
|
extname: '.html',
|
|
cache: true
|
|
});
|
|
var src = '<h2>Welcome to {{ name | capitalize}}, ' +
|
|
'access time: {{date|date: "%Y-%m-%d %H:%M:%S"}}</h2>';
|
|
var ctx = {
|
|
name: 'Liquid',
|
|
date: new Date()
|
|
};
|
|
engine.parseAndRender(src, ctx)
|
|
.then(function(html) {
|
|
return engine.renderFile('hello', ctx);
|
|
})
|
|
.then(function(html) {
|
|
document.body.innerHTML += html
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|