mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 21:00:40 -07:00
docs: demo for globals, for #286
This commit is contained in:
@@ -0,0 +1 @@
|
||||
<small>{{title}}</small>
|
||||
@@ -0,0 +1,7 @@
|
||||
<html>
|
||||
<head><meta name="title" content="{{title}}"></head>
|
||||
<body>
|
||||
{% block %}{% endblock %}
|
||||
{% render "footer.liquid" %}
|
||||
</body>
|
||||
</html>
|
||||
@@ -2,7 +2,8 @@ const { Liquid } = require('liquidjs')
|
||||
|
||||
const engine = new Liquid({
|
||||
root: __dirname,
|
||||
extname: '.liquid'
|
||||
extname: '.liquid',
|
||||
globals: {title: 'LiquidJS Demo'}
|
||||
})
|
||||
|
||||
engine.registerTag('header', {
|
||||
@@ -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)
|
||||
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user