Skip to content

Commit

Permalink
docs: demo for globals, for #286
Browse files Browse the repository at this point in the history
  • Loading branch information
harttle committed Dec 22, 2020
1 parent 626f911 commit 8a85005
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions demo/nodejs/footer.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<small>{{title}}</small>
7 changes: 7 additions & 0 deletions demo/nodejs/html.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<html>
<head><meta name="title" content="{{title}}"></head>
<body>
{% block %}{% endblock %}
{% render "footer.liquid" %}
</body>
</html>
8 changes: 4 additions & 4 deletions demo/nodejs/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const { Liquid } = require('liquidjs')
const { Liquid } = require('../..')

const engine = new Liquid({
root: __dirname,
extname: '.liquid'
extname: '.liquid',
globals: {title: 'LiquidJS Demo'}
})

engine.registerTag('header', {
Expand All @@ -17,8 +18,7 @@ engine.registerTag('header', {
})

const ctx = {
todos: ['fork and clone', 'make it better', 'make a pull request'],
title: 'Welcome to liquidjs!'
todos: ['fork and clone', 'make it better', 'make a pull request']
}

engine.renderFile('todolist', ctx)
Expand Down
6 changes: 3 additions & 3 deletions demo/nodejs/todolist.liquid
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{%header content: "welcome to liquid" | capitalize%}

{% layout 'html.liquid' %}
{%header content: title | capitalize%}
<ul>
{% for todo in todos %}
<li>{{forloop.index}} - {{todo}}</li>
{% endfor %}
</ul>
</ul>

0 comments on commit 8a85005

Please sign in to comment.