mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-14 20:00:39 -07:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4171b2e023 | ||
|
|
d20a043fbb | ||
|
|
3dbab238ae | ||
|
|
d7d00421e2 | ||
|
|
c33d8f6828 | ||
|
|
c13a16fdd6 | ||
|
|
4bd35de867 | ||
|
|
29f53304bc | ||
|
|
cbebb00ef1 | ||
|
|
64a9eb79c5 | ||
|
|
852c6ad453 | ||
|
|
f432aade6a | ||
|
|
aa49b4f117 | ||
|
|
fc9ebdb90f | ||
|
|
7ee87008c7 | ||
|
|
677e8511e6 | ||
|
|
b51b0dabca | ||
|
|
1cc7249a71 | ||
|
|
a626de632c | ||
|
|
83a8e2d310 | ||
|
|
c37b330751 | ||
|
|
c8de8bcde2 | ||
|
|
2015f683b8 | ||
|
|
d14f18520b | ||
|
|
c0524a83f3 | ||
|
|
dde7b3b389 | ||
|
|
84bbb3432f | ||
|
|
1c5b934250 | ||
|
|
a2caeb559b | ||
|
|
81e6861b73 | ||
|
|
9038d56ce7 | ||
|
|
bad72005fe | ||
|
|
4dffb27e95 | ||
|
|
f38ea63c14 | ||
|
|
57bdf17dea | ||
|
|
0040485188 | ||
|
|
42d799055a | ||
|
|
8a881ac69a | ||
|
|
7a2e036c79 | ||
|
|
a31e0c6275 | ||
|
|
7df4d5d62c | ||
|
|
22b7e55fc9 | ||
|
|
0238cf2c44 | ||
|
|
601f2e48fc | ||
|
|
8cb0137362 | ||
|
|
dee4303fad | ||
|
|
9ba352ef04 | ||
|
|
4793a83bd6 | ||
|
|
af4fe1b330 | ||
|
|
5f5c62a51e | ||
|
|
21f4d6bf08 | ||
|
|
ba54bec82f | ||
|
|
c2e1bc7055 | ||
|
|
2055258193 | ||
|
|
d65ea14b9f | ||
|
|
f1b4c4fe14 | ||
|
|
6af631b77b | ||
|
|
d504c8107e | ||
|
|
c0181aec31 | ||
|
|
22a7a85d50 | ||
|
|
044be8253d | ||
|
|
8a629980d9 | ||
|
|
5412c5a39f | ||
|
|
b7445f26d6 | ||
|
|
3213c6d23a | ||
|
|
829afc24a7 | ||
|
|
0049a56864 | ||
|
|
f8e0587542 | ||
|
|
c3c57a560b | ||
|
|
5378f2709b | ||
|
|
d6876bd9ec | ||
|
|
31c39561c9 | ||
|
|
d828c4021e | ||
|
|
4d4a2d04ec | ||
|
|
bc9d8f92af | ||
|
|
4ece4e208f | ||
|
|
4ad3d2a52b | ||
|
|
fa7cd8f4ff | ||
|
|
87360d5207 | ||
|
|
19891b2df0 | ||
|
|
5f634b0b5e | ||
|
|
9f597843c9 | ||
|
|
887b736f39 | ||
|
|
7a3689067b | ||
|
|
5b43520d78 | ||
|
|
ea38a9e1f5 | ||
|
|
fa5b731daf | ||
|
|
96829b5293 | ||
|
|
4cf7215a67 | ||
|
|
50006db26d | ||
|
|
2d81223d99 | ||
|
|
3038115c21 | ||
|
|
fdbf4b838a | ||
|
|
7ab0e96419 | ||
|
|
48484fe52f | ||
|
|
14d1956232 | ||
|
|
c3e7859cdd | ||
|
|
c3de3fbb19 | ||
|
|
b5cfd2d2c5 | ||
|
|
36f84e4b3c | ||
|
|
63b5658604 | ||
|
|
c79700ef1a | ||
|
|
6755462056 | ||
|
|
02806b2257 | ||
|
|
d0fb5ccece | ||
|
|
b7144f9b75 | ||
|
|
88fc05732f | ||
|
|
44b1aac096 | ||
|
|
42043b6944 | ||
|
|
61f146432d | ||
|
|
220b705b73 | ||
|
|
ef85bd9192 | ||
|
|
8e9e10fdb4 | ||
|
|
f668a5cc41 | ||
|
|
098f5164e7 | ||
|
|
432f878bb6 | ||
|
|
aa54dad36e |
@@ -1,3 +1,4 @@
|
||||
node_modules
|
||||
dist
|
||||
demo
|
||||
coverage
|
||||
|
||||
+12
-1
@@ -1,11 +1,22 @@
|
||||
{
|
||||
"extends": "standard",
|
||||
"env": {
|
||||
"mocha": true,
|
||||
"es6": true,
|
||||
"browser": true,
|
||||
"node": true
|
||||
},
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": [
|
||||
"mocha",
|
||||
"standard",
|
||||
"@typescript-eslint",
|
||||
"promise"
|
||||
]
|
||||
],
|
||||
"rules": {
|
||||
"no-var": 2,
|
||||
"prefer-const": 2,
|
||||
"no-unused-vars": "off",
|
||||
"@typescript-eslint/no-unused-vars": ["error", { "vars": "all", "args": "after-used", "ignoreRestSiblings": false }]
|
||||
}
|
||||
}
|
||||
|
||||
+10
-35
@@ -1,41 +1,16 @@
|
||||
# Logs
|
||||
logs
|
||||
# logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
# cache
|
||||
.rpt2_cache
|
||||
coverage/
|
||||
.nyc_output/
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
# modules
|
||||
node_modules/
|
||||
build/
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules
|
||||
jspm_packages
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# vim
|
||||
# editors
|
||||
.*.swp
|
||||
package-lock.json
|
||||
.vscode
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
test/
|
||||
+17
-7
@@ -1,9 +1,19 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "node"
|
||||
- "lts/*"
|
||||
- "4"
|
||||
before_script:
|
||||
- npm install -g mocha
|
||||
after_script:
|
||||
- npm run lcov && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage
|
||||
- "10"
|
||||
- "8"
|
||||
- "6"
|
||||
jobs:
|
||||
include:
|
||||
- stage: test
|
||||
name: 'Linting'
|
||||
script: npm run lint
|
||||
- name: 'Coverage'
|
||||
script: npm run coverage-coveralls
|
||||
- stage: release
|
||||
if: branch = master
|
||||
script: skip
|
||||
deploy:
|
||||
provider: script
|
||||
skip_cleanup: true
|
||||
script: npx semantic-release
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
# [7.2.0](https://github.com/harttle/liquidjs/compare/v7.1.0...v7.2.0) (2019-02-20)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* override output/tag delimiter, fixes [#54](https://github.com/harttle/liquidjs/issues/54) ([d20a043](https://github.com/harttle/liquidjs/commit/d20a043))
|
||||
|
||||
# [7.1.0](https://github.com/harttle/liquidjs/compare/v7.0.2...v7.1.0) (2019-02-20)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* throw an Error if delimiter not matched ([c33d8f6](https://github.com/harttle/liquidjs/commit/c33d8f6))
|
||||
|
||||
# [7.0.0](https://github.com/harttle/liquidjs/compare/v6.4.3...v7.0.0) (2019-02-14)
|
||||
|
||||
|
||||
### chore
|
||||
|
||||
* **TypeScript:** ship Liquid to class ([1cc7249](https://github.com/harttle/liquidjs/commit/1cc7249))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* **TypeScript:** calling `Liquid()` without `new` now becomes invalid
|
||||
|
||||
## [6.4.3](https://github.com/harttle/liquidjs/compare/v6.4.2...v6.4.3) (2019-02-13)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* better index.d.ts and a demo ([2015f68](https://github.com/harttle/liquidjs/commit/2015f68)), closes [#98](https://github.com/harttle/liquidjs/issues/98)
|
||||
|
||||
## [6.4.2](https://github.com/harttle/liquidjs/compare/v6.4.1...v6.4.2) (2019-01-28)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **CI:** e2e not building cjs ([dde7b3b](https://github.com/harttle/liquidjs/commit/dde7b3b))
|
||||
|
||||
## [6.4.1](https://github.com/harttle/liquidjs/compare/v6.4.0...v6.4.1) (2019-01-28)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* regenerator undefined ([a2caeb5](https://github.com/harttle/liquidjs/commit/a2caeb5))
|
||||
@@ -9,6 +9,8 @@
|
||||
[](https://david-dm.org/harttle/liquidjs)
|
||||
[](https://david-dm.org/harttle/liquidjs?type=dev)
|
||||
[](https://github.com/harttle/liquidjs/blob/master/LICENSE)
|
||||
[](http://github.com/harttle/liquidjs)
|
||||
[](https://github.com/harttle/liquidjs)
|
||||
|
||||
This is a liquid implementation for both Node.js and browsers. Website: <http://harttle.github.io/liquidjs/>, Live Demo: <https://jsfiddle.net/6u40xbzs/>
|
||||
|
||||
@@ -16,7 +18,7 @@ This is a liquid implementation for both Node.js and browsers. Website: <http://
|
||||
|
||||
* Fully compatible to [shopify][shopify/liquid], with all [tags][tags] and [filters][filters] implemented
|
||||
* Support layout(extend) and include syntax
|
||||
* In pure JavaScript with [any-promise][any-promise] as the only one dependency
|
||||
* In pure JavaScript with Promise-based API
|
||||
|
||||
**Differences**
|
||||
|
||||
@@ -24,7 +26,9 @@ Though being compatible with [Ruby Liquid](https://github.com/shopify/liquid) is
|
||||
|
||||
* Dynamic file locating (enabled by default), which means layout/partial name can be an variable in liquidjs. See [#51](https://github.com/harttle/liquidjs/issues/51).
|
||||
* Truthy and Falsy. All values except `undefined`, `null`, `false` are truthy, whereas in Ruby Liquid all except `nil` and `false` are truthy. See [#26](https://github.com/harttle/liquidjs/pull/26).
|
||||
* Number Rendering. Since JavaScript do not distinguish `float` and `integer`, we cannot either convert between them nor render regarding their type. See [#59](https://github.com/harttle/liquidjs/issues/59).
|
||||
* Number Rendering. Since JavaScript do not distinguish `float` and `integer`, we cannot either convert between them nor render regarding to their type. See [#59](https://github.com/harttle/liquidjs/issues/59).
|
||||
* [.to_liquid()](https://github.com/Shopify/liquid/wiki/Introduction-to-Drops) has a `.toLiquid()` alias and and the JavaScript `.toString()` is aliased to `.to_s()`.
|
||||
* [.to_s()](https://www.rubydoc.info/gems/liquid/Liquid/Drop) uses `JSON.prototype.stringify` as default, rather than Ruby's inspect.
|
||||
|
||||
## TOC
|
||||
|
||||
@@ -41,12 +45,14 @@ Though being compatible with [Ruby Liquid](https://github.com/shopify/liquid) is
|
||||
* [Register Tags](#register-tags), [Builtin Tags](https://github.com/harttle/liquidjs/wiki/Builtin-Tags)
|
||||
* [Operators](https://github.com/harttle/liquidjs/wiki/Operators)
|
||||
* [Whitespace Control](https://github.com/harttle/liquidjs/wiki/Whitespace-Control)
|
||||
* [Contribute Guidelines](#contribute-guidelines)
|
||||
|
||||
## Render from String
|
||||
|
||||
Install as Node.js dependency:
|
||||
|
||||
```bash
|
||||
# You'll need a promise-polyfill for Node.js < 4
|
||||
npm install --save liquidjs
|
||||
```
|
||||
|
||||
@@ -54,7 +60,7 @@ Parse and Render:
|
||||
|
||||
```javascript
|
||||
var Liquid = require('liquidjs');
|
||||
var engine = Liquid();
|
||||
var engine = new Liquid();
|
||||
|
||||
engine
|
||||
.parseAndRender('{{name | capitalize}}', {name: 'alice'})
|
||||
@@ -77,7 +83,7 @@ engine
|
||||
## Render from File
|
||||
|
||||
```javascript
|
||||
var engine = Liquid({
|
||||
var engine = new Liquid({
|
||||
root: path.resolve(__dirname, 'views/'), // dirs to lookup layouts/includes
|
||||
extname: '.liquid' // the extname used for layouts/includes, defaults ""
|
||||
});
|
||||
@@ -186,9 +192,13 @@ Otherwise, undefined variables will cause an exception. Defaults to `false`.
|
||||
|
||||
* `trim_tag_left` is similiar to `trim_tag_right`, whereas the `\n` is exclusive. Defaults to `false`. See [Whitespace Control][whitespace control] for details.
|
||||
|
||||
* `trim_value_right` is used to strip blank characters (including ` `, `\t`, and `\r`) from the right of values (`{{ }}`) until `\n` (inclusive). Defaults to `false`.
|
||||
* `trim_output_right` is used to strip blank characters (including ` `, `\t`, and `\r`) from the right of values (`{{ }}`) until `\n` (inclusive). Defaults to `false`.
|
||||
|
||||
* `trim_value_left` is similiar to `trim_value_right`, whereas the `\n` is exclusive. Defaults to `false`. See [Whitespace Control][whitespace control] for details.
|
||||
* `trim_output_left` is similiar to `trim_output_right`, whereas the `\n` is exclusive. Defaults to `false`. See [Whitespace Control][whitespace control] for details.
|
||||
|
||||
* `tag_delimiter_left` and `tag_delimiter_right` are used to override the delimiter for liquid tags.
|
||||
|
||||
* `output_delimiter_left` and `output_delimiter_right` are used to override the delimiter for liquid outputs.
|
||||
|
||||
* `greedy` is used to specify whether `trim_left`/`trim_right` is greedy. When set to `true`, all consecutive blank characters including `\n` will be trimed regardless of line breaks. Defaults to `true`.
|
||||
|
||||
@@ -206,7 +216,7 @@ Filter arguments will be passed to the registered filter function, for example:
|
||||
engine.registerFilter('add', (initial, arg1, arg2) => initial + arg1 + arg2)
|
||||
```
|
||||
|
||||
See existing filter implementations here: <https://github.com/harttle/liquidjs/blob/master/filters.js>
|
||||
See existing filter implementations here: <https://github.com/harttle/liquidjs/tree/master/src/builtin/filters>
|
||||
|
||||
## Register Tags
|
||||
|
||||
@@ -226,7 +236,33 @@ engine.registerTag('upper', {
|
||||
* `parse`: Read tokens from `remainTokens` until your end token.
|
||||
* `render`: Combine scope data with your parsed tokens into HTML string.
|
||||
|
||||
See existing tag implementations here: <https://github.com/harttle/liquidjs/blob/master/tags/>
|
||||
See existing tag implementations here: <https://github.com/harttle/liquidjs/tree/master/src/builtin/tags>
|
||||
|
||||
## Plugin API
|
||||
|
||||
A pack of tags or filters can be encapsulated into a **plugin**, which will be typically installed via npm.
|
||||
|
||||
```javascript
|
||||
engine.plugin(require('./some-plugin'));
|
||||
|
||||
// some-plugin.js
|
||||
module.exports = function (Liquid) {
|
||||
// here `this` refers to the engine instance
|
||||
// `Liquid` provides facilities to implement tags and filters
|
||||
this.registerFilter('foo', x => x);
|
||||
}
|
||||
```
|
||||
|
||||
Plugin List:
|
||||
|
||||
* To add your plugin, contact me or simply send a PR.
|
||||
|
||||
## Contribute Guidelines
|
||||
|
||||
This repo uses [eslint](https://eslint.org/) to check code style, [semantic-release](https://github.com/semantic-release/semantic-release) to generate changelog and publish to npm and Github Releases.
|
||||
|
||||
* Code Style: <https://github.com/standard/eslint-config-standard>, `npm run lint` to check locally.
|
||||
* Commit Message: <https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits>
|
||||
|
||||
[nunjucks]: http://mozilla.github.io/nunjucks/
|
||||
[liquid-node]: https://github.com/sirlantis/liquid-node
|
||||
|
||||
@@ -1,28 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title></title>
|
||||
<script src="../../dist/liquid.js"></script>
|
||||
<title>liquidjs for the browser</title>
|
||||
<script src="node_modules/liquidjs/dist/liquid.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script>
|
||||
var engine = window.Liquid({
|
||||
// root: './',
|
||||
var engine = new window.Liquid({
|
||||
extname: '.html',
|
||||
cache: true
|
||||
});
|
||||
var src = '<h2>Welcome to {{ name | capitalize}}, ' +
|
||||
'access time: {{date|date: "%Y-%m-%d %H:%M:%S"}}</h2>';
|
||||
'access time: {{date|date: "%Y-%m-%d %H:%M:%S"}}</h2>';
|
||||
var ctx = {
|
||||
name: 'Liquid',
|
||||
date: new Date()
|
||||
};
|
||||
engine.parseAndRender(src, ctx)
|
||||
.then(function(html) {
|
||||
document.body.innerHTML += html
|
||||
return engine.renderFile('hello', ctx);
|
||||
})
|
||||
.then(function(html) {
|
||||
|
||||
Generated
+220
@@ -0,0 +1,220 @@
|
||||
{
|
||||
"name": "liquidjs-demo-browser",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"async": {
|
||||
"version": "1.5.2",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz",
|
||||
"integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=",
|
||||
"dev": true
|
||||
},
|
||||
"colors": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz",
|
||||
"integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=",
|
||||
"dev": true
|
||||
},
|
||||
"corser": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/corser/-/corser-2.0.1.tgz",
|
||||
"integrity": "sha1-jtolLsqrWEDc2XXOuQ2TcMgZ/4c=",
|
||||
"dev": true
|
||||
},
|
||||
"debug": {
|
||||
"version": "3.2.6",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz",
|
||||
"integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ms": "2.1.1"
|
||||
}
|
||||
},
|
||||
"ecstatic": {
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmjs.org/ecstatic/-/ecstatic-3.3.1.tgz",
|
||||
"integrity": "sha512-/rrctvxZ78HMI/tPIsqdvFKHHscxR3IJuKrZI2ZoUgkt2SiufyLFBmcco+aqQBIu6P1qBsUNG3drAAGLx80vTQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"he": "1.2.0",
|
||||
"mime": "1.6.0",
|
||||
"minimist": "1.2.0",
|
||||
"url-join": "2.0.5"
|
||||
}
|
||||
},
|
||||
"eventemitter3": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.0.tgz",
|
||||
"integrity": "sha512-ivIvhpq/Y0uSjcHDcOIccjmYjGLcP09MFGE7ysAwkAvkXfpZlC985pH2/ui64DKazbTW/4kN3yqozUxlXzI6cA==",
|
||||
"dev": true
|
||||
},
|
||||
"follow-redirects": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.7.0.tgz",
|
||||
"integrity": "sha512-m/pZQy4Gj287eNy94nivy5wchN3Kp+Q5WgUPNy5lJSZ3sgkVKSYV/ZChMAQVIgx1SqfZ2zBZtPA2YlXIWxxJOQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"debug": "3.2.6"
|
||||
}
|
||||
},
|
||||
"he": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
|
||||
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==",
|
||||
"dev": true
|
||||
},
|
||||
"http-proxy": {
|
||||
"version": "1.17.0",
|
||||
"resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.17.0.tgz",
|
||||
"integrity": "sha512-Taqn+3nNvYRfJ3bGvKfBSRwy1v6eePlm3oc/aWVxZp57DQr5Eq3xhKJi7Z4hZpS8PC3H4qI+Yly5EmFacGuA/g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"eventemitter3": "3.1.0",
|
||||
"follow-redirects": "1.7.0",
|
||||
"requires-port": "1.0.0"
|
||||
}
|
||||
},
|
||||
"http-server": {
|
||||
"version": "0.11.1",
|
||||
"resolved": "https://registry.npmjs.org/http-server/-/http-server-0.11.1.tgz",
|
||||
"integrity": "sha512-6JeGDGoujJLmhjiRGlt8yK8Z9Kl0vnl/dQoQZlc4oeqaUoAKQg94NILLfrY3oWzSyFaQCVNTcKE5PZ3cH8VP9w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"colors": "1.0.3",
|
||||
"corser": "2.0.1",
|
||||
"ecstatic": "3.3.1",
|
||||
"http-proxy": "1.17.0",
|
||||
"opener": "1.4.3",
|
||||
"optimist": "0.6.1",
|
||||
"portfinder": "1.0.20",
|
||||
"union": "0.4.6"
|
||||
}
|
||||
},
|
||||
"liquidjs": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/liquidjs/-/liquidjs-7.0.0.tgz",
|
||||
"integrity": "sha512-/JL+VQUI++6iCS7JQ4fPPeji6vyvHCU/iuz2bLSiE0tn0eO3kf8GEyfaXnQUHSroy8SmJu7HQIvjvOErtYEvUg=="
|
||||
},
|
||||
"mime": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
|
||||
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
|
||||
"dev": true
|
||||
},
|
||||
"minimist": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
|
||||
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
|
||||
"dev": true
|
||||
},
|
||||
"mkdirp": {
|
||||
"version": "0.5.1",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
||||
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
},
|
||||
"dependencies": {
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
|
||||
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
|
||||
"integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==",
|
||||
"dev": true
|
||||
},
|
||||
"opener": {
|
||||
"version": "1.4.3",
|
||||
"resolved": "https://registry.npmjs.org/opener/-/opener-1.4.3.tgz",
|
||||
"integrity": "sha1-XG2ixdflgx6P+jlklQ+NZnSskLg=",
|
||||
"dev": true
|
||||
},
|
||||
"optimist": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz",
|
||||
"integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.10",
|
||||
"wordwrap": "0.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"minimist": {
|
||||
"version": "0.0.10",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz",
|
||||
"integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"portfinder": {
|
||||
"version": "1.0.20",
|
||||
"resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.20.tgz",
|
||||
"integrity": "sha512-Yxe4mTyDzTd59PZJY4ojZR8F+E5e97iq2ZOHPz3HDgSvYC5siNad2tLooQ5y5QHyQhc3xVqvyk/eNA3wuoa7Sw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"async": "1.5.2",
|
||||
"debug": "2.6.9",
|
||||
"mkdirp": "0.5.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"qs": {
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-2.3.3.tgz",
|
||||
"integrity": "sha1-6eha2+ddoLvkyOBHaghikPhjtAQ=",
|
||||
"dev": true
|
||||
},
|
||||
"requires-port": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
|
||||
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=",
|
||||
"dev": true
|
||||
},
|
||||
"union": {
|
||||
"version": "0.4.6",
|
||||
"resolved": "https://registry.npmjs.org/union/-/union-0.4.6.tgz",
|
||||
"integrity": "sha1-GY+9rrolTniLDvy2MLwR8kopWeA=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"qs": "2.3.3"
|
||||
}
|
||||
},
|
||||
"url-join": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/url-join/-/url-join-2.0.5.tgz",
|
||||
"integrity": "sha1-WvIvGMBSoACkjXuCxenC4v7tpyg=",
|
||||
"dev": true
|
||||
},
|
||||
"wordwrap": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz",
|
||||
"integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "liquidjs-demo-browser",
|
||||
"version": "1.0.0",
|
||||
"description": "Liquidjs Demo for Browser Usage",
|
||||
"main": "index.html",
|
||||
"scripts": {
|
||||
"start": "http-server -c-1 "
|
||||
},
|
||||
"author": "harttle <[email protected]>",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"http-server": "^0.11.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"liquidjs": "^7.0.0"
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -1,8 +1,8 @@
|
||||
var express = require('express')
|
||||
var app = express()
|
||||
var Liquid = require('../..')
|
||||
const express = require('express')
|
||||
const Liquid = require('../..')
|
||||
|
||||
var engine = Liquid({
|
||||
const app = express()
|
||||
const engine = new Liquid({
|
||||
root: __dirname, // for layouts and partials
|
||||
extname: '.liquid'
|
||||
})
|
||||
@@ -12,7 +12,7 @@ app.set('views', ['./partials', './views']) // 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']
|
||||
const todos = ['fork and clone', 'make it better', 'make a pull request']
|
||||
res.render('todolist', {
|
||||
todos: todos,
|
||||
title: 'Welcome to liquidjs!'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const app = require('./app.js')
|
||||
|
||||
app.listen(3000, function () {
|
||||
console.log('Example app listening on port 3000!')
|
||||
console.log('Express running: http://localhost:3000')
|
||||
})
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<ul>
|
||||
{% for todo in todos %}
|
||||
<li>{% include 'todo' id=forloop.index %}</li>
|
||||
<li>{% include 'todo', id:forloop.index %}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
const Liquid = require('liquidjs')
|
||||
|
||||
const engine = new Liquid({
|
||||
root: __dirname,
|
||||
extname: '.liquid'
|
||||
})
|
||||
|
||||
engine.registerTag('header', {
|
||||
parse: function (token) {
|
||||
const [key, val] = token.args.split(':')
|
||||
this[key] = val
|
||||
},
|
||||
render: function (scope, hash) {
|
||||
const title = this.liquid.evalValue(this.content, scope)
|
||||
return `<h1>${title}</h1>`
|
||||
}
|
||||
})
|
||||
|
||||
const ctx = {
|
||||
todos: ['fork and clone', 'make it better', 'make a pull request'],
|
||||
title: 'Welcome to liquidjs!'
|
||||
}
|
||||
|
||||
engine.renderFile('todolist', ctx)
|
||||
.then(console.log)
|
||||
.catch(err => console.error(err.stack))
|
||||
Generated
+12
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "Node.js demo for liquidjs",
|
||||
"requires": true,
|
||||
"lockfileVersion": 1,
|
||||
"dependencies": {
|
||||
"liquidjs": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/liquidjs/-/liquidjs-7.0.0.tgz",
|
||||
"integrity": "sha512-/JL+VQUI++6iCS7JQ4fPPeji6vyvHCU/iuz2bLSiE0tn0eO3kf8GEyfaXnQUHSroy8SmJu7HQIvjvOErtYEvUg=="
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "liquidjs-demo-nodejs",
|
||||
"description": "Node.js demo for liquidjs",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"liquidjs": "^7.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{%header content: "welcome to liquid" | capitalize%}
|
||||
|
||||
<ul>
|
||||
{% for todo in todos %}
|
||||
<li>{{forloop.index}} - {{todo}}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
@@ -0,0 +1,21 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
File diff suppressed because it is too large
Load Diff
Generated
+16737
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "react-liquidjs",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"dns": "^0.2.2",
|
||||
"html-react-parser": "^0.4.7",
|
||||
"liquidjs": "^6.0.1",
|
||||
"path": "^0.12.7",
|
||||
"react": "^16.5.2",
|
||||
"react-dom": "^16.5.2",
|
||||
"react-promise": "^2.0.3",
|
||||
"react-scripts": "2.0.4"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "react-app"
|
||||
},
|
||||
"browserslist": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not ie <= 11",
|
||||
"not op_mini all"
|
||||
]
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
@@ -0,0 +1,41 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="theme-color" content="#000000">
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is added to the
|
||||
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>React App</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>
|
||||
You need to enable JavaScript to run this app.
|
||||
</noscript>
|
||||
<div id="result"></div>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"short_name": "React App",
|
||||
"name": "Create React App Sample",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon.ico",
|
||||
"sizes": "64x64 32x32 24x24 16x16",
|
||||
"type": "image/x-icon"
|
||||
}
|
||||
],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#ffffff"
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
.App {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.App-logo {
|
||||
animation: App-logo-spin infinite 20s linear;
|
||||
height: 40vmin;
|
||||
}
|
||||
|
||||
.App-header {
|
||||
background-color: #282c34;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: calc(10px + 2vmin);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.App-link {
|
||||
color: #61dafb;
|
||||
}
|
||||
|
||||
@keyframes App-logo-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import React, { Component } from 'react';
|
||||
import logo from './logo.svg';
|
||||
import './App.css';
|
||||
|
||||
let path = require('path')
|
||||
let Liquid = require('liquidjs');
|
||||
|
||||
let config = require('./views/demo.liquid');
|
||||
let pageConfig = config.toString()
|
||||
|
||||
let Parser = require('html-react-parser');
|
||||
|
||||
class App extends Component {
|
||||
|
||||
componentDidMount() {
|
||||
|
||||
let engine = new Liquid({
|
||||
root: path.resolve(__dirname, 'views/'), // dirs to lookup layouts/includes
|
||||
extname: '.liquid' // the extname used for layouts/includes, defaults
|
||||
});
|
||||
|
||||
engine.registerFilter('image', d => {
|
||||
let img = `<img src="${d}" class="App-logo" alt="logo"></img>`;
|
||||
return img
|
||||
})
|
||||
|
||||
engine.renderFile(pageConfig, {name: 'alice', logo: logo })
|
||||
.then((htmlTemp) => {
|
||||
this.setState({ html: htmlTemp })
|
||||
}) // outputs "Alice"
|
||||
}
|
||||
|
||||
state = {
|
||||
html: []
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="App">
|
||||
{Parser(`${this.state.html}`)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default App;
|
||||
@@ -0,0 +1,9 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import App from './App';
|
||||
|
||||
it('renders without crashing', () => {
|
||||
const div = document.createElement('div');
|
||||
ReactDOM.render(<App />, div);
|
||||
ReactDOM.unmountComponentAtNode(div);
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
|
||||
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
|
||||
sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
|
||||
monospace;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import './index.css';
|
||||
import App from './App';
|
||||
import * as serviceWorker from './serviceWorker';
|
||||
|
||||
ReactDOM.render(<App />, document.getElementById('root'));
|
||||
|
||||
// If you want your app to work offline and load faster, you can change
|
||||
// unregister() to register() below. Note this comes with some pitfalls.
|
||||
// Learn more about service workers: http://bit.ly/CRA-PWA
|
||||
serviceWorker.unregister();
|
||||
@@ -0,0 +1,7 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3">
|
||||
<g fill="#61DAFB">
|
||||
<path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/>
|
||||
<circle cx="420.9" cy="296.5" r="45.7"/>
|
||||
<path d="M520.5 78.1z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.6 KiB |
@@ -0,0 +1,127 @@
|
||||
// In production, we register a service worker to serve assets from local cache.
|
||||
|
||||
// This lets the app load faster on subsequent visits in production, and gives
|
||||
// it offline capabilities. However, it also means that developers (and users)
|
||||
// will only see deployed updates on the "N+1" visit to a page, since previously
|
||||
// cached resources are updated in the background.
|
||||
|
||||
// To learn more about the benefits of this model, read https://goo.gl/KwvDNy.
|
||||
// This link also includes instructions on opting out of this behavior.
|
||||
|
||||
const isLocalhost = Boolean(
|
||||
window.location.hostname === 'localhost' ||
|
||||
// [::1] is the IPv6 localhost address.
|
||||
window.location.hostname === '[::1]' ||
|
||||
// 127.0.0.1/8 is considered localhost for IPv4.
|
||||
window.location.hostname.match(
|
||||
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
|
||||
)
|
||||
);
|
||||
|
||||
export function register(config) {
|
||||
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
|
||||
// The URL constructor is available in all browsers that support SW.
|
||||
const publicUrl = new URL(process.env.PUBLIC_URL, window.location);
|
||||
if (publicUrl.origin !== window.location.origin) {
|
||||
// Our service worker won't work if PUBLIC_URL is on a different origin
|
||||
// from what our page is served on. This might happen if a CDN is used to
|
||||
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
|
||||
return;
|
||||
}
|
||||
|
||||
window.addEventListener('load', () => {
|
||||
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
|
||||
|
||||
if (isLocalhost) {
|
||||
// This is running on localhost. Let's check if a service worker still exists or not.
|
||||
checkValidServiceWorker(swUrl, config);
|
||||
|
||||
// Add some additional logging to localhost, pointing developers to the
|
||||
// service worker/PWA documentation.
|
||||
navigator.serviceWorker.ready.then(() => {
|
||||
console.log(
|
||||
'This web app is being served cache-first by a service ' +
|
||||
'worker. To learn more, visit https://goo.gl/SC7cgQ'
|
||||
);
|
||||
});
|
||||
} else {
|
||||
// Is not local host. Just register service worker
|
||||
registerValidSW(swUrl, config);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function registerValidSW(swUrl, config) {
|
||||
navigator.serviceWorker
|
||||
.register(swUrl)
|
||||
.then(registration => {
|
||||
registration.onupdatefound = () => {
|
||||
const installingWorker = registration.installing;
|
||||
installingWorker.onstatechange = () => {
|
||||
if (installingWorker.state === 'installed') {
|
||||
if (navigator.serviceWorker.controller) {
|
||||
// At this point, the old content will have been purged and
|
||||
// the fresh content will have been added to the cache.
|
||||
// It's the perfect time to display a "New content is
|
||||
// available; please refresh." message in your web app.
|
||||
console.log('New content is available; please refresh.');
|
||||
|
||||
// Execute callback
|
||||
if (config.onUpdate) {
|
||||
config.onUpdate(registration);
|
||||
}
|
||||
} else {
|
||||
// At this point, everything has been precached.
|
||||
// It's the perfect time to display a
|
||||
// "Content is cached for offline use." message.
|
||||
console.log('Content is cached for offline use.');
|
||||
|
||||
// Execute callback
|
||||
if (config.onSuccess) {
|
||||
config.onSuccess(registration);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error during service worker registration:', error);
|
||||
});
|
||||
}
|
||||
|
||||
function checkValidServiceWorker(swUrl, config) {
|
||||
// Check if the service worker can be found. If it can't reload the page.
|
||||
fetch(swUrl)
|
||||
.then(response => {
|
||||
// Ensure service worker exists, and that we really are getting a JS file.
|
||||
if (
|
||||
response.status === 404 ||
|
||||
response.headers.get('content-type').indexOf('javascript') === -1
|
||||
) {
|
||||
// No service worker found. Probably a different app. Reload the page.
|
||||
navigator.serviceWorker.ready.then(registration => {
|
||||
registration.unregister().then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
// Service worker found. Proceed as normal.
|
||||
registerValidSW(swUrl, config);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
console.log(
|
||||
'No internet connection found. App is running in offline mode.'
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export function unregister() {
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.ready.then(registration => {
|
||||
registration.unregister();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<header className="App-header">
|
||||
{{ logo | image }}
|
||||
<h2>Welcome {{name | capitalize}}</h2>
|
||||
<p>
|
||||
Edit <code>src/App.js</code> and save to reload.
|
||||
</p>
|
||||
<p>
|
||||
You are using liquidjs & Reactjs
|
||||
</p>
|
||||
<a
|
||||
className="App-link"
|
||||
href="https://reactjs.org"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Learn React
|
||||
</a>
|
||||
</header>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,25 @@
|
||||
import Liquid from 'liquidjs'
|
||||
|
||||
const engine = new Liquid({
|
||||
root: __dirname,
|
||||
extname: '.liquid'
|
||||
})
|
||||
|
||||
engine.registerTag('header', {
|
||||
parse: function (token) {
|
||||
const [key, val] = token.args.split(':')
|
||||
this[key] = val
|
||||
},
|
||||
render: function (scope, hash) {
|
||||
const title = this.liquid.evalValue(this['content'], scope)
|
||||
return `<h1>${title}</h1>`
|
||||
}
|
||||
})
|
||||
|
||||
const ctx = {
|
||||
todos: ['fork and clone', 'make it better', 'make a pull request'],
|
||||
title: 'Welcome to liquidjs!'
|
||||
}
|
||||
|
||||
// console.log('isTruthy:', isTruthy('a string here'));
|
||||
engine.renderFile('todolist', ctx).then(console.log)
|
||||
Generated
+8701
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "liquidjs-demo-typescript",
|
||||
"description": "TypeScript demo for liquidjs",
|
||||
"main": "index.ts",
|
||||
"scripts": {
|
||||
"start": "ts-node index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"liquidjs": "^7.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ts-node": "^8.0.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{%header content: "welcome to liquid" | capitalize%}
|
||||
|
||||
<ul>
|
||||
{% for todo in todos %}
|
||||
<li>{{forloop.index}} - {{todo}}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
declare const _default: {
|
||||
'join': (v: any, arg: any) => any;
|
||||
'last': (v: any) => any;
|
||||
'first': (v: any) => any;
|
||||
'map': (arr: any, arg: any) => any;
|
||||
'reverse': (v: any) => any;
|
||||
'sort': (v: any, arg: any) => any;
|
||||
'size': (v: any) => any;
|
||||
'slice': (v: any, begin: any, length: any) => any;
|
||||
'uniq': (arr: any) => any;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
declare const _default: {
|
||||
'date': (v: any, arg: any) => any;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
declare function escape(str: any): string;
|
||||
declare const _default: {
|
||||
'escape': typeof escape;
|
||||
'escape_once': (str: any) => string;
|
||||
'newline_to_br': (v: any) => any;
|
||||
'strip_html': (v: any) => string;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+46
@@ -0,0 +1,46 @@
|
||||
declare const _default: {
|
||||
'join': (v: any, arg: any) => any;
|
||||
'last': (v: any) => any;
|
||||
'first': (v: any) => any;
|
||||
'map': (arr: any, arg: any) => any;
|
||||
'reverse': (v: any) => any;
|
||||
'sort': (v: any, arg: any) => any;
|
||||
'size': (v: any) => any;
|
||||
'slice': (v: any, begin: any, length: any) => any;
|
||||
'uniq': (arr: any) => any;
|
||||
'default': (v: any, arg: any) => any;
|
||||
'date': (v: any, arg: any) => any;
|
||||
'url_decode': (x: any) => any;
|
||||
'url_encode': (x: any) => any;
|
||||
'abs': (v: any) => number;
|
||||
'ceil': (v: any) => number;
|
||||
'divided_by': (v: any, arg: any) => number;
|
||||
'floor': (v: any) => number;
|
||||
'minus': (l: any, r: any) => any;
|
||||
'modulo': (l: any, r: any) => any;
|
||||
'round': (v: any, arg: any) => number;
|
||||
'plus': (l: any, r: any) => any;
|
||||
'times': (v: any, arg: any) => number;
|
||||
'append': (v: any, arg: any) => any;
|
||||
'prepend': (v: any, arg: any) => any;
|
||||
'capitalize': (str: any) => string;
|
||||
'concat': (v: any, arg: any) => any;
|
||||
'lstrip': (v: any) => string;
|
||||
'downcase': (v: any) => any;
|
||||
'upcase': (str: any) => string;
|
||||
'remove': (v: any, arg: any) => any;
|
||||
'remove_first': (v: any, l: any) => any;
|
||||
'replace': (v: any, pattern: any, replacement: any) => string;
|
||||
'replace_first': (v: any, arg1: any, arg2: any) => string;
|
||||
'rstrip': (str: any) => string;
|
||||
'split': (v: any, arg: any) => string[];
|
||||
'strip': (v: any) => string;
|
||||
'strip_newlines': (v: any) => string;
|
||||
'truncate': (v: any, l: any, o: any) => any;
|
||||
'truncatewords': (v: any, l: any, o: any) => any;
|
||||
'escape': (str: any) => string;
|
||||
'escape_once': (str: any) => string;
|
||||
'newline_to_br': (v: any) => any;
|
||||
'strip_html': (v: any) => string;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
declare const _default: {
|
||||
'abs': (v: any) => number;
|
||||
'ceil': (v: any) => number;
|
||||
'divided_by': (v: any, arg: any) => number;
|
||||
'floor': (v: any) => number;
|
||||
'minus': (l: any, r: any) => any;
|
||||
'modulo': (l: any, r: any) => any;
|
||||
'round': (v: any, arg: any) => number;
|
||||
'plus': (l: any, r: any) => any;
|
||||
'times': (v: any, arg: any) => number;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
declare const _default: {
|
||||
'default': (v: any, arg: any) => any;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
declare const _default: {
|
||||
'append': (v: any, arg: any) => any;
|
||||
'prepend': (v: any, arg: any) => any;
|
||||
'capitalize': (str: any) => string;
|
||||
'concat': (v: any, arg: any) => any;
|
||||
'lstrip': (v: any) => string;
|
||||
'downcase': (v: any) => any;
|
||||
'upcase': (str: any) => string;
|
||||
'remove': (v: any, arg: any) => any;
|
||||
'remove_first': (v: any, l: any) => any;
|
||||
'replace': (v: any, pattern: any, replacement: any) => string;
|
||||
'replace_first': (v: any, arg1: any, arg2: any) => string;
|
||||
'rstrip': (str: any) => string;
|
||||
'split': (v: any, arg: any) => string[];
|
||||
'strip': (v: any) => string;
|
||||
'strip_newlines': (v: any) => string;
|
||||
'truncate': (v: any, l: any, o: any) => any;
|
||||
'truncatewords': (v: any, l: any, o: any) => any;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
declare const _default: {
|
||||
'url_decode': (x: any) => any;
|
||||
'url_encode': (x: any) => any;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
declare const _default: {
|
||||
parse: (token: any) => void;
|
||||
render: (scope: any) => Promise<string>;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
declare const _default: {
|
||||
parse: (token: any, remainTokens: any) => void;
|
||||
render: (scope: any) => Promise<any>;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
declare const _default: {
|
||||
render: () => Promise<never>;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Token from 'src/parser/token';
|
||||
import Scope from 'src/scope/scope';
|
||||
declare const _default: {
|
||||
parse: (tagToken: TagToken, remainTokens: Token[]) => void;
|
||||
render: (scope: Scope) => Promise<void>;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
declare const _default: {
|
||||
parse: (tagToken: any, remainTokens: any) => void;
|
||||
render: (scope: any) => any;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
declare const _default: {
|
||||
parse: (tagToken: any, remainTokens: any) => void;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
declare const _default: {
|
||||
render: () => Promise<never>;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
declare const _default: {
|
||||
parse: (tagToken: any) => void;
|
||||
render: (scope: any) => any;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Scope from 'src/scope/scope';
|
||||
declare const _default: {
|
||||
parse: (token: TagToken) => void;
|
||||
render: (scope: Scope) => number;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
declare function parse(tagToken: any, remainTokens: any): void;
|
||||
declare function render(scope: any, hash: any): Promise<any>;
|
||||
declare const _default: {
|
||||
parse: typeof parse;
|
||||
render: typeof render;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
declare const _default: {
|
||||
parse: (tagToken: any, remainTokens: any) => void;
|
||||
render: (scope: any) => any;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
declare const _default: {
|
||||
parse: (token: any) => void;
|
||||
render: (scope: any, hash: any) => Promise<any>;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
declare const _default: {
|
||||
parse: (token: any) => void;
|
||||
render: (scope: any) => any;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
import ITagImplOptions from 'src/template/tag/itag-impl-options';
|
||||
declare const tags: {
|
||||
[key: string]: ITagImplOptions;
|
||||
};
|
||||
export default tags;
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
declare const _default: {
|
||||
parse: (token: any, remainTokens: any) => void;
|
||||
render: (scope: any, hash: any) => Promise<any>;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
declare const _default: {
|
||||
parse: (tagToken: any, remainTokens: any) => void;
|
||||
render: () => any;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
declare const _default: {
|
||||
parse: (tagToken: any, remainTokens: any) => void;
|
||||
render: (scope: any, hash: any) => Promise<string>;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
declare const _default: {
|
||||
parse: (tagToken: any, remainTokens: any) => void;
|
||||
render: (scope: any) => any;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
import IFS from './ifs';
|
||||
declare const _default: IFS;
|
||||
export default _default;
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
export default interface IFS {
|
||||
exists: (filepath?: string) => Promise<boolean>;
|
||||
readFile: (filepath: string) => Promise<string>;
|
||||
resolve: (root: string, file: string, ext: string) => string;
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
import IFS from './ifs';
|
||||
declare const fs: IFS;
|
||||
export default fs;
|
||||
Vendored
+48
@@ -0,0 +1,48 @@
|
||||
export interface LiquidOptions {
|
||||
/** `root` is a directory or an array of directories to resolve layouts and includes, as well as the filename passed in when calling `.renderFile()`. If an array, the files are looked up in the order they occur in the array. Defaults to `["."]` */
|
||||
root?: string | string[];
|
||||
/** `extname` is used to lookup the template file when filepath doesn't include an extension name. Eg: setting to `".html"` will allow including file by basename. Defaults to `""`. */
|
||||
extname?: string;
|
||||
/** `cache` indicates whether or not to cache resolved templates. Defaults to `false`. */
|
||||
cache?: boolean;
|
||||
/** `dynamicPartials`: if set, treat `<filepath>` parameter in `{%include filepath %}`, `{%layout filepath%}` as a variable, otherwise as a literal value. Defaults to `true`. */
|
||||
dynamicPartials?: boolean;
|
||||
/** `strict_filters` is used to enable strict filter existence. If set to `false`, undefined filters will be rendered as empty string. Otherwise, undefined filters will cause an exception. Defaults to `false`. */
|
||||
strict_filters?: boolean;
|
||||
/** `strict_variables` is used to enable strict variable derivation. If set to `false`, undefined variables will be rendered as empty string. Otherwise, undefined variables will cause an exception. Defaults to `false`. */
|
||||
strict_variables?: boolean;
|
||||
/** `trim_tag_right` is used to strip blank characters (including ` `, `\t`, and `\r`) from the right of tags (`{% %}`) until `\n` (inclusive). Defaults to `false`. */
|
||||
trim_tag_right?: boolean;
|
||||
/** `trim_tag_left` is similar to `trim_tag_right`, whereas the `\n` is exclusive. Defaults to `false`. See Whitespace Control for details. */
|
||||
trim_tag_left?: boolean;
|
||||
/** ``trim_output_right` is used to strip blank characters (including ` `, `\t`, and `\r`) from the right of values (`{{ }}`) until `\n` (inclusive). Defaults to `false`. */
|
||||
trim_output_right?: boolean;
|
||||
/** `trim_output_left` is similar to `trim_output_right`, whereas the `\n` is exclusive. Defaults to `false`. See Whitespace Control for details. */
|
||||
trim_output_left?: boolean;
|
||||
/** `tag_delimiter_left` and `tag_delimiter_right` are used to override the delimiter for liquid tags **/
|
||||
tag_delimiter_left?: string;
|
||||
tag_delimiter_right?: string;
|
||||
/** `output_delimiter_left` and `output_delimiter_right` are used to override the delimiter for liquid outputs **/
|
||||
output_delimiter_left?: string;
|
||||
output_delimiter_right?: string;
|
||||
/** `greedy` is used to specify whether `trim_left`/`trim_right` is greedy. When set to `true`, all consecutive blank characters including `\n` will be trimed regardless of line breaks. Defaults to `true`. */
|
||||
greedy?: boolean;
|
||||
}
|
||||
export interface NormalizedOptions extends LiquidOptions {
|
||||
root?: string[];
|
||||
}
|
||||
export interface NormalizedFullOptions extends NormalizedOptions {
|
||||
root: string[];
|
||||
extname: string;
|
||||
cache: boolean;
|
||||
dynamicPartials: boolean;
|
||||
strict_filters: boolean;
|
||||
strict_variables: boolean;
|
||||
trim_tag_right: boolean;
|
||||
trim_tag_left: boolean;
|
||||
trim_output_right: boolean;
|
||||
trim_output_left: boolean;
|
||||
greedy: boolean;
|
||||
}
|
||||
export declare function normalize(options: LiquidOptions): NormalizedOptions;
|
||||
export declare function applyDefault(options: NormalizedOptions): NormalizedFullOptions;
|
||||
Vendored
+2291
File diff suppressed because it is too large
Load Diff
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
import Scope from './scope/scope';
|
||||
import * as Types from './types';
|
||||
import ITemplate from './template/itemplate';
|
||||
import ITagImplOptions from './template/tag/itag-impl-options';
|
||||
import { isTruthy, isFalsy, evalExp, evalValue } from './render/syntax';
|
||||
import { LiquidOptions, NormalizedFullOptions } from './liquid-options';
|
||||
export default class Liquid {
|
||||
options: NormalizedFullOptions;
|
||||
private cache;
|
||||
private parser;
|
||||
private renderer;
|
||||
private tokenizer;
|
||||
constructor(opts?: LiquidOptions);
|
||||
parse(html: string, filepath?: string): any[];
|
||||
render(tpl: Array<ITemplate>, ctx?: object, opts?: LiquidOptions): Promise<string>;
|
||||
parseAndRender(html: string, ctx?: object, opts?: LiquidOptions): Promise<string>;
|
||||
getTemplate(file: any, opts?: LiquidOptions): Promise<any>;
|
||||
renderFile(file: any, ctx?: object, opts?: LiquidOptions): Promise<string>;
|
||||
evalValue(str: string, scope: Scope): any;
|
||||
registerFilter(name: any, filter: any): void;
|
||||
registerTag(name: string, tag: ITagImplOptions): void;
|
||||
plugin(plugin: any): any;
|
||||
express(): (filePath: string, ctx: object, cb: (err: Error, html?: string) => void) => void;
|
||||
static default: typeof Liquid;
|
||||
static isTruthy: typeof isTruthy;
|
||||
static isFalsy: typeof isFalsy;
|
||||
static evalExp: typeof evalExp;
|
||||
static evalValue: typeof evalValue;
|
||||
static Types: typeof Types;
|
||||
}
|
||||
Vendored
+2273
-2683
File diff suppressed because it is too large
Load Diff
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+2
-1
File diff suppressed because one or more lines are too long
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import Token from './token';
|
||||
export default class DelimitedToken extends Token {
|
||||
trimLeft: boolean;
|
||||
trimRight: boolean;
|
||||
constructor(raw: any, value: any, pos: any, input: any, file: any, line: any);
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
import Token from './token';
|
||||
export default class HTMLToken extends Token {
|
||||
constructor(str: any, begin: any, input: any, file: any, line: any);
|
||||
}
|
||||
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
export declare const quoted: RegExp;
|
||||
export declare const quoteBalanced: RegExp;
|
||||
export declare const integer: RegExp;
|
||||
export declare const number: RegExp;
|
||||
export declare const bool: RegExp;
|
||||
export declare const identifier: RegExp;
|
||||
export declare const subscript: RegExp;
|
||||
export declare const literal: RegExp;
|
||||
export declare const variable: RegExp;
|
||||
export declare const rangeLimit: RegExp;
|
||||
export declare const range: RegExp;
|
||||
export declare const rangeCapture: RegExp;
|
||||
export declare const value: RegExp;
|
||||
export declare const hash: RegExp;
|
||||
export declare const hashCapture: RegExp;
|
||||
export declare const tagLine: RegExp;
|
||||
export declare const literalLine: RegExp;
|
||||
export declare const variableLine: RegExp;
|
||||
export declare const numberLine: RegExp;
|
||||
export declare const boolLine: RegExp;
|
||||
export declare const quotedLine: RegExp;
|
||||
export declare const rangeLine: RegExp;
|
||||
export declare const integerLine: RegExp;
|
||||
export declare const valueDeclaration: RegExp;
|
||||
export declare const valueList: RegExp;
|
||||
export declare const filter: RegExp;
|
||||
export declare const filterCapture: RegExp;
|
||||
export declare const filterLine: RegExp;
|
||||
export declare const operators: RegExp[];
|
||||
export declare function isInteger(str: any): boolean;
|
||||
export declare function isLiteral(str: any): boolean;
|
||||
export declare function isRange(str: any): boolean;
|
||||
export declare function isVariable(str: any): boolean;
|
||||
export declare function matchValue(str: any): RegExpExecArray;
|
||||
export declare function parseLiteral(str: any): any;
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
import DelimitedToken from './delimited-token';
|
||||
export default class OutputToken extends DelimitedToken {
|
||||
constructor(raw: any, value: any, pos: any, input: any, file: any, line: any);
|
||||
}
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
import Token from 'src/parser/token';
|
||||
import ITemplate from 'src/template/itemplate';
|
||||
declare type parseToken = (token: Token, remainTokens: Array<Token>) => ITemplate;
|
||||
declare type eventHandler = ((arg?: Token | ITemplate) => void);
|
||||
export default class ParseStream {
|
||||
private tokens;
|
||||
private handlers;
|
||||
private stopRequested;
|
||||
private parseToken;
|
||||
constructor(tokens: Array<Token>, parseToken: parseToken);
|
||||
on(name: string, cb: eventHandler): this;
|
||||
trigger(event: string, arg?: Token | ITemplate): boolean;
|
||||
start(): this;
|
||||
stop(): this;
|
||||
}
|
||||
export {};
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
import Liquid from 'src/liquid';
|
||||
import ParseStream from './parse-stream';
|
||||
import Token from './token';
|
||||
import Tag from 'src/template/tag/tag';
|
||||
import Output from 'src/template/output';
|
||||
import HTML from 'src/template/html';
|
||||
export default class Parser {
|
||||
liquid: Liquid;
|
||||
constructor(liquid: Liquid);
|
||||
parse(tokens: Array<Token>): any[];
|
||||
parseToken(token: Token, remainTokens: Array<Token>): Tag | Output | HTML;
|
||||
parseStream(tokens: Array<Token>): ParseStream;
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import DelimitedToken from './delimited-token';
|
||||
export default class TagToken extends DelimitedToken {
|
||||
name: string;
|
||||
args: string;
|
||||
constructor(raw: any, value: any, pos: any, input: any, file: any, line: any);
|
||||
}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
export default class Token {
|
||||
type: string;
|
||||
line: number;
|
||||
col: number;
|
||||
raw: string;
|
||||
input: string;
|
||||
file: string;
|
||||
value: string;
|
||||
constructor(raw: any, col: any, input: any, file: any, line: any);
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import { NormalizedFullOptions } from '../liquid-options';
|
||||
export default class Tokenizer {
|
||||
options: NormalizedFullOptions;
|
||||
constructor(options?: NormalizedFullOptions);
|
||||
tokenize(input: string, file?: string): any[];
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
import Token from 'src/parser/token';
|
||||
import { NormalizedFullOptions } from 'src/liquid-options';
|
||||
export default function whiteSpaceCtrl(tokens: Token[], options: NormalizedFullOptions): void;
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
export default class Render {
|
||||
renderTemplates(templates: any, scope: any): Promise<string>;
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
export declare function evalExp(exp: any, scope: any): any;
|
||||
export declare function evalValue(str: any, scope: any): any;
|
||||
export declare function isTruthy(val: any): boolean;
|
||||
export declare function isFalsy(val: any): boolean;
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
declare enum BlockMode {
|
||||
OUTPUT = 0,
|
||||
STORE = 1
|
||||
}
|
||||
export default BlockMode;
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
import { NormalizedFullOptions } from '../liquid-options';
|
||||
import BlockMode from './block-mode';
|
||||
export default class Scope {
|
||||
opts: NormalizedFullOptions;
|
||||
contexts: Array<object>;
|
||||
blocks: object;
|
||||
blockMode: BlockMode;
|
||||
constructor(ctx?: object, opts?: NormalizedFullOptions);
|
||||
getAll(): object;
|
||||
get(path: string): any;
|
||||
set(path: string, v: any): void;
|
||||
unshift(ctx: object): number;
|
||||
push(ctx: object): number;
|
||||
pop(ctx?: object): object;
|
||||
findContextFor(key: string, filter?: ((conttext: object) => boolean)): object;
|
||||
readProperty(obj: any, key: any): any;
|
||||
propertyAccessSeq(str: any): any[];
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
export declare class CaptureScope {
|
||||
}
|
||||
export declare class AssignScope {
|
||||
}
|
||||
export declare class IncrementScope {
|
||||
}
|
||||
export declare class DecrementScope {
|
||||
}
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
import Scope from 'src/scope/scope';
|
||||
declare type impl = (value: any, ...args: any[]) => any;
|
||||
export default class Filter {
|
||||
name: string;
|
||||
impl: impl;
|
||||
args: string[];
|
||||
private static impls;
|
||||
constructor(str: string, strictFilters?: boolean);
|
||||
parseArgs(argList: string): string[];
|
||||
render(value: any, scope: Scope): any;
|
||||
static register(name: any, filter: any): void;
|
||||
static clear(): void;
|
||||
}
|
||||
export {};
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
import Template from 'src/template/template';
|
||||
import ITemplate from 'src/template/itemplate';
|
||||
import Token from 'src/parser/token';
|
||||
export default class extends Template implements ITemplate {
|
||||
str: string;
|
||||
constructor(token: Token);
|
||||
render(): Promise<string>;
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import Scope from 'src/scope/scope';
|
||||
import Token from 'src/parser/token';
|
||||
export default interface ITemplate {
|
||||
token: Token;
|
||||
render(scope: Scope): Promise<string>;
|
||||
}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
import Value from './value';
|
||||
import Template from 'src/template/template';
|
||||
import ITemplate from 'src/template/itemplate';
|
||||
import Scope from 'src/scope/scope';
|
||||
import OutputToken from 'src/parser/output-token';
|
||||
export default class Output extends Template implements ITemplate {
|
||||
value: Value;
|
||||
constructor(token: OutputToken, strictFilters?: boolean);
|
||||
render(scope: Scope): Promise<string>;
|
||||
}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Key-Value Pairs Representing Tag Arguments
|
||||
* Example:
|
||||
* For the markup `{% include 'head.html' foo='bar' %}`,
|
||||
* hash['foo'] === 'bar'
|
||||
*/
|
||||
export default class Hash {
|
||||
[key: string]: any;
|
||||
constructor(markup: any, scope: any);
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import Scope from 'src/scope/scope';
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Token from 'src/parser/token';
|
||||
import Hash from 'src/template/tag/hash';
|
||||
import ITagImpl from './itag-impl';
|
||||
export default interface ITagImplOptions {
|
||||
parse?: (this: ITagImpl, token: TagToken, remainingTokens: Array<Token>) => void;
|
||||
render?: (this: ITagImpl, scope: Scope, hash: Hash) => any | Promise<any>;
|
||||
}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
import Liquid from 'src/liquid';
|
||||
import ITagImplOptions from './itag-impl-options';
|
||||
export default interface ITagImpl extends ITagImplOptions {
|
||||
liquid: Liquid;
|
||||
}
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
import Scope from 'src/scope/scope';
|
||||
import ITagImplOptions from './itag-impl-options';
|
||||
import Liquid from 'src/liquid';
|
||||
import Template from 'src/template/template';
|
||||
import ITemplate from 'src/template/itemplate';
|
||||
import TagToken from 'src/parser/tag-token';
|
||||
import Token from 'src/parser/token';
|
||||
export default class Tag extends Template implements ITemplate {
|
||||
name: string;
|
||||
token: TagToken;
|
||||
private impl;
|
||||
static impls: {
|
||||
[key: string]: ITagImplOptions;
|
||||
};
|
||||
constructor(token: TagToken, tokens: Token[], liquid: Liquid);
|
||||
render(scope: Scope): Promise<string>;
|
||||
static register(name: string, tag: ITagImplOptions): void;
|
||||
static clear(): void;
|
||||
}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
import Token from 'src/parser/token';
|
||||
export default class Template {
|
||||
token: Token;
|
||||
constructor(token: any);
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
import Scope from 'src/scope/scope';
|
||||
export default class {
|
||||
initial: any;
|
||||
filters: Array<any>;
|
||||
constructor(str: string, strictFilters?: boolean);
|
||||
value(scope: Scope): any;
|
||||
}
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
export { AssignScope, CaptureScope, IncrementScope, DecrementScope } from './scope/scopes';
|
||||
export { ParseError, TokenizationError, RenderBreakError, AssertionError } from './util/error';
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user