feature: root option allows array of strings

This commit is contained in:
harttle
2016-10-31 23:21:28 +08:00
parent 377c805230
commit 6dd836f157
18 changed files with 313 additions and 106 deletions
+22
View File
@@ -0,0 +1,22 @@
var express = require('express');
var app = express();
var Liquid = require('../..');
var engine = Liquid({
root: __dirname, // for layouts and partials
extname: '.liquid'
});
app.engine('liquid', engine.express()); // register liquid engine
app.set('views', __dirname); // specify the views directory
app.set('view engine', 'liquid'); // set to default
app.get('/', function (req, res) {
var todos = ['fork and clone', 'make it better', 'make a pull request'];
res.render('todolist', {
todos: todos,
title: 'Welcome to shopify-liquid!'
});
});
module.exports = app;
-1
View File
@@ -1 +0,0 @@
<footer>Copyright @ 2016, Harttle</footer>
-11
View File
@@ -1,11 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1>Welcome to shopify-liquid!</h1>
{% include 'bar' %}
</body>
</html>
+2 -16
View File
@@ -1,20 +1,6 @@
var express = require('express');
var app = express();
var Liquid = require('..');
var engine = Liquid({
root: __dirname, // for layouts and partials
extname: '.liquid'
});
app.engine('liquid', engine.express()); // register liquid engine
app.set('views', __dirname); // specify the views directory
app.set('view engine', 'liquid'); // set to default
app.get('/', function (req, res) {
res.render('foo');
});
const app = require('./app.js');
app.listen(3000, function () {
console.log('Example app listening on port 3000!');
});
+14
View File
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{title}}</title>
</head>
<body>
<h1>{{title}}</h1>
{% block %}
<footer> {% block footer %} </footer>
</body>
</html>
+1
View File
@@ -0,0 +1 @@
{{id}} - {{todo}}
+11
View File
@@ -0,0 +1,11 @@
{% layout 'layout' %}
<ul>
{% for todo in todolist %}
<li>{% include 'todo' id=forloop.index %}</li>
{% endfor %}
</ul>
{% block 'footer' %}
Copyright @ 2016, Harttle
{% endblock %}