rename to liquidjs

This commit is contained in:
harttle
2017-07-17 01:08:51 +08:00
parent e91cc8c950
commit cbde48971a
4 changed files with 47 additions and 46 deletions
+24 -23
View File
@@ -1,34 +1,35 @@
# shopify-liquid # liquidjs
[![npm](https://img.shields.io/npm/v/shopify-liquid.svg)](https://www.npmjs.org/package/shopify-liquid) [![npm](https://img.shields.io/npm/v/liquidjs.svg)](https://www.npmjs.org/package/liquidjs)
[![Build Status](https://travis-ci.org/harttle/shopify-liquid.svg?branch=master)](https://travis-ci.org/harttle/shopify-liquid) [![Build Status](https://travis-ci.org/harttle/liquidjs.svg?branch=master)](https://travis-ci.org/harttle/liquidjs)
[![Coveralls](https://img.shields.io/coveralls/harttle/shopify-liquid.svg)](https://coveralls.io/github/harttle/shopify-liquid?branch=master) [![Coveralls](https://img.shields.io/coveralls/harttle/liquidjs.svg)](https://coveralls.io/github/harttle/liquidjs?branch=master)
[![GitHub issues](https://img.shields.io/github/issues-closed/harttle/shopify-liquid.svg)](https://github.com/harttle/shopify-liquid/issues) [![GitHub issues](https://img.shields.io/github/issues-closed/harttle/liquidjs.svg)](https://github.com/harttle/liquidjs/issues)
A Liquid template engine with a wide range of tags and filters, A Liquid engine implementation for both Node.js and browsers, with all [shopify/liquid][shopify/liquid] features.
for both Node.js and browsers. Formerly known as shopify-liquid.
Here's a live demo: <http://harttle.com/shopify-liquid/>
Live Demo: <http://harttle.com/liquidjs/>
> The Liquid template engine is implemented in Ruby originally, > The Liquid template engine is implemented in Ruby originally,
> which is used by [Jekyll][jekyll] and [Github Pages][gh]. > which is used by [Jekyll][jekyll] and [Github Pages][gh].
Features: Features:
* A wide range of [filters](https://github.com/harttle/shopify-liquid/wiki/Builtin-Filters) and [tags](https://github.com/harttle/shopify-liquid/wiki/Builtin-Tags) * A wide range of [filters](https://github.com/harttle/liquidjs/wiki/Builtin-Filters) and [tags](https://github.com/harttle/liquidjs/wiki/Builtin-Tags)
* Easy tag/filter registration, allows async tags * Easy tag/filter registration, allows async tags
* [any-promise][any-promise] * [any-promise][any-promise]
API Reference: API Reference:
* Builtin Tags: <https://github.com/harttle/shopify-liquid/wiki/Builtin-Tags> * Builtin Tags: <https://github.com/harttle/liquidjs/wiki/Builtin-Tags>
* Builtin Filters: <https://github.com/harttle/shopify-liquid/wiki/Builtin-Filters> * Builtin Filters: <https://github.com/harttle/liquidjs/wiki/Builtin-Filters>
* Operators: <https://github.com/harttle/shopify-liquid/wiki/Operators> * Operators: <https://github.com/harttle/liquidjs/wiki/Operators>
* Whitespace Control: <https://github.com/harttle/shopify-liquid/wiki/Whitespace-Control> * Whitespace Control: <https://github.com/harttle/liquidjs/wiki/Whitespace-Control>
Installation: Installation:
```bash ```bash
npm install --save shopify-liquid npm install --save liquidjs
``` ```
## Render from String ## Render from String
@@ -36,7 +37,7 @@ npm install --save shopify-liquid
Parse and Render: Parse and Render:
```javascript ```javascript
var Liquid = require('shopify-liquid'); var Liquid = require('liquidjs');
var engine = Liquid(); var engine = Liquid();
engine.parseAndRender('{{name | capitalize}}', {name: 'alice'}) engine.parseAndRender('{{name | capitalize}}', {name: 'alice'})
@@ -126,11 +127,11 @@ And `window.Liquid` is what you want. There's also a [demo](demo/browser/).
var engine = window.Liquid(); var engine = window.Liquid();
var src = '{{ name | capitalize}}'; var src = '{{ name | capitalize}}';
var ctx = { var ctx = {
name: 'welcome to Shopify Liquid' name: 'welcome to liquidjs'
}; };
engine.parseAndRender(src, ctx) engine.parseAndRender(src, ctx)
.then(function(html) { .then(function(html) {
// html === Welcome to Shopify Liquid // html === Welcome to liquidjs
}); });
</script> </script>
</body> </body>
@@ -194,7 +195,7 @@ engine.registerFilter('upper', function(v){
}); });
``` ```
> See existing filter implementations: <https://github.com/harttle/shopify-liquid/blob/master/filters.js> > See existing filter implementations: <https://github.com/harttle/liquidjs/blob/master/filters.js>
## Register Tags ## Register Tags
@@ -211,7 +212,7 @@ engine.registerTag('upper', {
}); });
``` ```
> See existing tag implementations: <https://github.com/harttle/shopify-liquid/blob/master/tags/> > See existing tag implementations: <https://github.com/harttle/liquidjs/blob/master/tags/>
## Contribution Guide ## Contribution Guide
@@ -221,11 +222,11 @@ engine.registerTag('upper', {
[nunjucks]: http://mozilla.github.io/nunjucks/ [nunjucks]: http://mozilla.github.io/nunjucks/
[liquid-node]: https://github.com/sirlantis/liquid-node [liquid-node]: https://github.com/sirlantis/liquid-node
[shopify-liquid]: https://shopify.github.io/liquid/ [shopify/liquid]: https://shopify.github.io/liquid/
[jekyll]: http://jekyllrb.com/ [jekyll]: http://jekyllrb.com/
[gh]: https://pages.github.com/ [gh]: https://pages.github.com/
[releases]: https://github.com/harttle/shopify-liquid/releases [releases]: https://github.com/harttle/liquidjs/releases
[any-promise]: https://github.com/kevinbeaty/any-promise [any-promise]: https://github.com/kevinbeaty/any-promise
[test]: https://github.com/harttle/shopify-liquid/tree/master/test [test]: https://github.com/harttle/liquidjs/tree/master/test
[caniuse-promises]: http://caniuse.com/#feat=promises [caniuse-promises]: http://caniuse.com/#feat=promises
[whitespace control]: https://github.com/harttle/shopify-liquid/wiki/Whitespace-Control [whitespace control]: https://github.com/harttle/liquidjs/wiki/Whitespace-Control
+16 -16
View File
@@ -1,22 +1,22 @@
var express = require('express'); var express = require('express')
var app = express(); var app = express()
var Liquid = require('../..'); var Liquid = require('../..')
var engine = Liquid({ var engine = Liquid({
root: __dirname, // for layouts and partials root: __dirname, // for layouts and partials
extname: '.liquid' extname: '.liquid'
}); })
app.engine('liquid', engine.express()); // register liquid engine app.engine('liquid', engine.express()) // register liquid engine
app.set('views', ['./partials', './views']); // specify the views directory app.set('views', ['./partials', './views']) // specify the views directory
app.set('view engine', 'liquid'); // set to default app.set('view engine', 'liquid') // set to default
app.get('/', function (req, res) { app.get('/', function (req, res) {
var todos = ['fork and clone', 'make it better', 'make a pull request']; var todos = ['fork and clone', 'make it better', 'make a pull request']
res.render('todolist', { res.render('todolist', {
todos: todos, todos: todos,
title: 'Welcome to shopify-liquid!' title: 'Welcome to liquidjs!'
}); })
}); })
module.exports = app; module.exports = app
+2 -2
View File
@@ -1,14 +1,14 @@
{ {
"name": "express-demo", "name": "express-demo",
"version": "1.0.0", "version": "1.0.0",
"description": "Express Demo Using Shopify-Liquid", "description": "Express Demo Using liquidjs",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"start": "node index.js", "start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"author": "harttle", "author": "harttle",
"license": "ISC", "license": "MIT",
"dependencies": { "dependencies": {
"express": "^4.14.0" "express": "^4.14.0"
} }
+5 -5
View File
@@ -1,7 +1,7 @@
{ {
"name": "shopify-liquid", "name": "liquidjs",
"version": "1.9.0", "version": "1.9.0",
"description": "A feature-rich Liquid template engine for Node.js and browsers, with compliance with the Ruby version.", "description": "A Liquid template engine for Node.js and browsers, with all shopify/liquid features.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"lint": "eslint src/ test/", "lint": "eslint src/ test/",
@@ -13,7 +13,7 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/harttle/shopify-liquid.git" "url": "git+https://github.com/harttle/liquidjs.git"
}, },
"keywords": [ "keywords": [
"liquid", "liquid",
@@ -25,9 +25,9 @@
"author": "Harttle", "author": "Harttle",
"license": "MIT", "license": "MIT",
"bugs": { "bugs": {
"url": "https://github.com/harttle/shopify-liquid/issues" "url": "https://github.com/harttle/liquidjs/issues"
}, },
"homepage": "https://github.com/harttle/shopify-liquid#readme", "homepage": "https://github.com/harttle/liquidjs#readme",
"dependencies": { "dependencies": {
"any-promise": "^1.3.0" "any-promise": "^1.3.0"
}, },