mirror of
https://github.com/harttle/liquidjs.git
synced 2026-10-03 09:05:14 -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({
|
const engine = new Liquid({
|
||||||
root: __dirname,
|
root: __dirname,
|
||||||
extname: '.liquid'
|
extname: '.liquid',
|
||||||
|
globals: {title: 'LiquidJS Demo'}
|
||||||
})
|
})
|
||||||
|
|
||||||
engine.registerTag('header', {
|
engine.registerTag('header', {
|
||||||
@@ -17,8 +18,7 @@ engine.registerTag('header', {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const ctx = {
|
const ctx = {
|
||||||
todos: ['fork and clone', 'make it better', 'make a pull request'],
|
todos: ['fork and clone', 'make it better', 'make a pull request']
|
||||||
title: 'Welcome to liquidjs!'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
engine.renderFile('todolist', ctx)
|
engine.renderFile('todolist', ctx)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{%header content: "welcome to liquid" | capitalize%}
|
{% layout 'html.liquid' %}
|
||||||
|
{%header content: title | capitalize%}
|
||||||
<ul>
|
<ul>
|
||||||
{% for todo in todos %}
|
{% for todo in todos %}
|
||||||
<li>{{forloop.index}} - {{todo}}</li>
|
<li>{{forloop.index}} - {{todo}}</li>
|
||||||
|
|||||||
Reference in New Issue
Block a user