mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-20 06:50:47 -07:00
Add xhr support for render file in browser.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
access time: {{date|date: "%Y-%m-%d %H:%M:%S"}}
|
||||
@@ -0,0 +1 @@
|
||||
<h2>Welcome to {{ name | capitalize}}, {% include 'date.html' %}</h2>
|
||||
+12
-6
@@ -8,19 +8,25 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h2 id="header"></h2>
|
||||
<script>
|
||||
var engine = window.Liquid();
|
||||
|
||||
var src = 'Welcome to {{ name | capitalize}}, ' +
|
||||
'access time: {{date|date: "%Y-%m-%d %H:%M:%S"}}';
|
||||
var engine = window.Liquid({
|
||||
// root: './',
|
||||
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) {
|
||||
document.getElementById('header').innerHTML = html;
|
||||
document.body.innerHTML += html
|
||||
return engine.renderFile('hello', ctx);
|
||||
})
|
||||
.then(function(html) {
|
||||
document.body.innerHTML += html
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user