Compare commits

...
191 Commits
Author SHA1 Message Date
harttle c13a16fdd6 7.0.2 2019-02-20 10:02:10 +08:00
harttle 4bd35de867 chore: use white list to publish npm 2019-02-20 10:01:09 +08:00
harttle 29f53304bc 7.0.1 2019-02-19 23:55:38 +08:00
harttle cbebb00ef1 fix: unit test on Node.js 6 2019-02-19 23:25:08 +08:00
harttle 64a9eb79c5 style: fix unused vars in unit test 2019-02-19 23:01:59 +08:00
harttle 852c6ad453 refactor: remove mock-fs from dev dependency 2019-02-19 22:28:27 +08:00
harttle f432aade6a chore(TypeScript): remove mock-fs 2019-02-17 21:37:13 +08:00
harttle aa49b4f117 chore(TypeScript): fix unit tests and coverage 2019-02-17 20:46:33 +08:00
harttle fc9ebdb90f chore(TypeScript): fix linting and generate .d.ts 2019-02-17 18:20:04 +08:00
harttle 7ee87008c7 chore(TypeScript): demo for typescript 2019-02-17 14:22:13 +08:00
harttle 677e8511e6 chore(TypeScript): refactor objects into classes
fix: `Nil`(null, undefined) now renders as empty string
change: `parser.parseValue()` renamed to `parser.parseOutput`
change: registered tags/filters become static and shared across different liquid instances
2019-02-17 04:55:30 +08:00
semantic-release-bot b51b0dabca chore(release): 7.0.0 [skip ci]
# [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
2019-02-14 16:02:23 +00:00
harttle 1cc7249a71 chore(TypeScript): ship Liquid to class
BREAKING CHANGE: calling `Liquid()` without `new` now becomes invalid
2019-02-14 23:53:40 +08:00
harttle a626de632c chore(CI): remove node_js 4 2019-02-14 23:15:29 +08:00
harttle 83a8e2d310 chore(CI): skip unit test on node_js 4 2019-02-14 23:11:13 +08:00
harttle c37b330751 chore(typescript): ship to TypeScript 2019-02-14 22:33:45 +08:00
semantic-release-bot c8de8bcde2 chore(release): 6.4.3 [skip ci]
## [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)
2019-02-13 12:13:27 +00:00
harttle 2015f683b8 fix: better index.d.ts and a demo
The demo is located at demo/typescript/index.ts , working on #98
2019-02-13 20:07:13 +08:00
semantic-release-bot d14f18520b chore(release): 6.4.2 [skip ci]
## [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))
2019-01-28 17:34:02 +00:00
Jun Yang c0524a83f3 chore: remove build from e2e, check es5 after published 2019-01-29 01:28:02 +08:00
Jun Yang dde7b3b389 fix(CI): e2e not building cjs 2019-01-29 01:08:52 +08:00
semantic-release-bot 84bbb3432f chore(release): 6.4.1 [skip ci]
## [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))
2019-01-28 16:44:56 +00:00
Jun Yang 1c5b934250 chore(CI): update package-lock.json 2019-01-29 00:39:19 +08:00
Jun Yang a2caeb559b fix: regenerator undefined 2019-01-29 00:26:08 +08:00
harttle 81e6861b73 chore(Changelog): add semantic release plugins 2019-01-28 20:33:33 +08:00
harttle 9038d56ce7 chore(Changelog): add @semantic-release/changelog as dev dependency 2019-01-28 20:26:50 +08:00
harttle bad72005fe chore(CI): add @semantic-release/changelog plugin
working on #100
2019-01-28 20:21:16 +08:00
harttle 4dffb27e95 feat(Drop): liquid_method_missing and to_s
close #97
2019-01-28 19:53:04 +08:00
harttle f38ea63c14 chore(CI): mv lint and covereage to test phase 2019-01-28 18:57:25 +08:00
harttle 57bdf17dea chore(CI): downgrade rollup-plugin-babel 2019-01-28 18:46:41 +08:00
harttle 0040485188 chore(CI): skip_cleanup for node_modules 2019-01-28 18:22:20 +08:00
harttle 42d799055a chore(CI): use nodejs_8 for linting 2019-01-28 18:11:25 +08:00
harttle 8a881ac69a style: align to [email protected] 2019-01-28 18:06:47 +08:00
harttle 7a2e036c79 chore(package): update package-lock.json 2019-01-28 17:30:34 +08:00
harttle a31e0c6275 chore(CI): test use build matrix 2019-01-28 17:27:00 +08:00
harttle 7df4d5d62c chore(CI): adjust build matrix 2019-01-28 16:29:59 +08:00
harttle 22b7e55fc9 chore(CI): assign node_js for each script 2019-01-28 15:40:32 +08:00
harttle 0238cf2c44 fix(CI): scirpt for the first stage not defined 2019-01-28 15:26:40 +08:00
harttle 601f2e48fc chore(CI): enable semantic release 2019-01-28 15:18:21 +08:00
harttle 8cb0137362 6.3.0 2019-01-21 15:25:11 +08:00
harttle dee4303fad feature: plugin API, working on #86 2019-01-21 15:24:13 +08:00
harttle 9ba352ef04 6.2.1 2019-01-21 14:54:07 +08:00
harttle 4793a83bd6 fix #101: Slice filter does not work on arrays 2019-01-21 14:52:08 +08:00
harttle af4fe1b330 6.2.0 2019-01-10 13:30:05 +08:00
harttle 5f5c62a51e fix banner link 2019-01-10 13:29:39 +08:00
oott123andJun Yang 21f4d6bf08 export types variable 2019-01-10 13:28:13 +08:00
oott123andJun Yang ba54bec82f feat: add typescript definitions 2019-01-10 13:28:13 +08:00
Jun Yang c2e1bc7055 6.1.1 2018-11-22 09:36:18 +08:00
Andrew BarclayandJun Yang 2055258193 fix assign tag regex to include linebreaks in value 2018-11-22 09:31:22 +08:00
harttle d65ea14b9f 6.1.0 2018-10-14 00:53:43 +08:00
steven anthonyandJun Yang f1b4c4fe14 Added react-liquidjs-demo 2018-10-10 19:59:43 +08:00
harttle 6af631b77b feature: url_decode, working on #94 2018-10-08 10:37:24 +08:00
Jun Yang d504c8107e 6.0.1 2018-10-06 12:20:13 +08:00
Jun Yang c0181aec31 remove dependency from 'util' 2018-10-01 23:08:39 +08:00
Jun Yang 22a7a85d50 test case for Regexp rendering 2018-10-01 23:00:49 +08:00
Jun Yang 044be8253d fixes #91 2018-10-01 22:51:40 +08:00
Jun Yang 8a629980d9 refactor: move fs util into template.js 2018-10-01 22:06:03 +08:00
harttle 5412c5a39f fixes #88 2018-09-29 16:45:11 +08:00
harttle b7445f26d6 6.0.0 2018-08-28 00:37:00 +08:00
harttle 3213c6d23a fix: ci 2018-08-28 00:27:44 +08:00
harttle 829afc24a7 fix: ci 2018-08-28 00:17:26 +08:00
harttle 0049a56864 fix: ci 2018-08-28 00:05:50 +08:00
harttle f8e0587542 fix: ci 2018-08-27 23:54:43 +08:00
harttle c3c57a560b fix: travis 2018-08-27 23:49:11 +08:00
harttle 5378f2709b test: cover all 2018-08-27 23:27:42 +08:00
harttle d6876bd9ec refactor: bundle template.js respectively 2018-08-27 21:37:39 +08:00
harttle 31c39561c9 feature: get nyc, babel and coveralls working 2018-08-26 21:54:35 +08:00
harttle d828c4021e fix: unit test on node6.x 2018-08-21 01:21:30 +08:00
harttle 4d4a2d04ec refactor 2018-08-21 01:18:13 +08:00
harttle bc9d8f92af refactor: import rollup 2018-08-20 23:58:41 +08:00
harttle 4ece4e208f 5.3.0-0 2018-08-17 01:34:57 +08:00
harttle 4ad3d2a52b modified: .eslintignore 2018-08-17 01:34:07 +08:00
harttle fa7cd8f4ff refactor: import babelify 2018-08-17 01:32:16 +08:00
harttle 87360d5207 refactor: mv es5 files to build/ 2018-08-16 23:20:13 +08:00
harttle 19891b2df0 refactor: es6 building and linting 2018-08-16 23:14:12 +08:00
harttle 5f634b0b5e refactor: moving all ES6 files to src/, working on #83 2018-08-16 00:22:46 +08:00
harttle 9f597843c9 5.2.0 2018-08-14 00:12:42 +08:00
harttle 887b736f39 test cases for stringify 2018-08-14 00:11:50 +08:00
harttle 7a3689067b feature: support toLiquid, working on #81 2018-08-14 00:11:50 +08:00
harttle 5b43520d78 feature: variable lookup respects to to_liquid, #81 2018-08-14 00:11:50 +08:00
harttle ea38a9e1f5 refactor: test/render.js use local scope 2018-08-14 00:11:50 +08:00
harttle fa5b731daf fix string type checking and circular reference, working on #81 2018-08-14 00:11:50 +08:00
harttle 96829b5293 fix: express demo, fixes #79 2018-07-25 21:51:42 +08:00
harttle 4cf7215a67 5.1.1 2018-07-24 19:39:12 +08:00
harttle 50006db26d fix: test/util/strftime.js 2018-07-24 19:38:47 +08:00
harttle 2d81223d99 update outdated packages 2018-07-24 19:37:21 +08:00
harttle 3038115c21 5.1.0 2018-07-24 14:53:47 +08:00
harttle fdbf4b838a add package.lock 2018-07-24 14:53:28 +08:00
harttle 7ab0e96419 feature: template string for {%include%} argument, #72 2018-07-24 14:49:23 +08:00
harttle 48484fe52f 5.0.2 2018-07-21 23:42:18 +08:00
harttle 14d1956232 test case for _.forOwn 2018-07-21 23:23:25 +08:00
harttle c3e7859cdd fix: increment/decrement independent from capture, #76 2018-07-21 23:19:28 +08:00
harttle c3de3fbb19 fix: post-increment, pre-decrement working on #76 2018-07-21 22:59:52 +08:00
harttle b5cfd2d2c5 fix: {%assign%} now adds a shading scope 2018-07-21 21:30:40 +08:00
harttle 36f84e4b3c refactor: pop the same context as the pushed one 2018-07-21 17:12:46 +08:00
harttle 63b5658604 refactor: src/scope.js 2018-07-21 17:02:18 +08:00
Ryan KennedyandJun Yang c79700ef1a fix: correctly understand variables with question marks
Fixes #77
2018-07-18 10:15:43 +08:00
harttle 6755462056 5.0.1 2018-07-16 15:04:40 +08:00
harttle 02806b2257 fix #75 2018-07-16 15:02:31 +08:00
harttle d0fb5ccece 5.0.0 2018-07-16 13:41:57 +08:00
harttle b7144f9b75 fix: linting 2018-07-07 01:22:40 +08:00
harttle 88fc05732f fix: tablerow cols defaults to 0, #74 2018-07-07 01:18:11 +08:00
Jun Yang 44b1aac096 remove any-promise, working on #73 2018-06-23 21:55:23 +08:00
Jun Yang 42043b6944 4.0.0 2018-05-12 23:10:36 +08:00
Jun Yang 61f146432d fix #59, divide numbers as it is 2018-05-12 22:58:43 +08:00
Jun Yang 220b705b73 3.1.3 2018-05-12 22:06:35 +08:00
Jun Yang ef85bd9192 fix #67: forloop.last, forloop.rindex, forloop.rindex0 incorrect if loop has a limit 2018-05-12 22:05:16 +08:00
Paul Robert LloydandJun Yang 8e9e10fdb4 Ensure strip_html filter uses same regex as Ruby Liquid 2018-05-09 10:41:25 +08:00
Jun Yang f668a5cc41 3.1.2 2018-04-07 19:49:46 +08:00
Jun Yang 098f5164e7 fix: linting 2018-04-07 19:48:46 +08:00
Jun Yang 432f878bb6 fix: support comma-separated arguments for static partials, fixes #62 2018-04-07 19:45:57 +08:00
Cory MawhorterandJun Yang aa54dad36e fix dupe name bug 2018-04-07 19:36:50 +08:00
Jun Yang c6ff1f7911 3.1.1 2018-03-05 01:34:00 +08:00
Jun Yang 11355cbf09 refactor: remove makefile 2018-03-05 01:31:12 +08:00
Jun Yang 7ccd0cb1e5 fix: branch coverage 2018-03-05 01:20:43 +08:00
Jun Yang 4326c223f3 fix #61: static filename not parsed for subdirectories 2018-03-05 00:58:26 +08:00
Jun Yang 78b6e35fbf fix: file path asserts for windows 2018-03-03 20:01:24 +08:00
Jun YangandGitHub e275368cb3 Update README.md 2018-01-17 11:01:58 +08:00
Jun YangandGitHub ca2b16a583 Update README.md 2018-01-17 10:48:05 +08:00
Jun YangandGitHub 86d0529a5e Update README.md 2018-01-17 10:47:11 +08:00
Jun YangandGitHub 400b93c88d Update README.md 2018-01-17 10:44:11 +08:00
harttle 22b41fd1a8 3.1.0 2018-01-12 10:55:38 +08:00
ChenLandJun Yang d7c7f32d4b make dist 2018-01-12 10:53:43 +08:00
ChenLandJun Yang 925df9a9b5 100% coverage 2018-01-12 10:53:43 +08:00
ChenLandJun Yang 7b696ed0d2 low version, skip tests 2018-01-12 10:53:43 +08:00
ChenLandJun Yang c55f0234eb Add xhr support for render file in browser. 2018-01-12 10:53:43 +08:00
harttle eee5649a47 fix package.json syntax 2017-12-31 12:32:13 +08:00
harttle 1048f4e0ab add engine spec 2017-12-31 12:29:32 +08:00
harttle 5c6d05092f fix: remove let for nodejs 4.x 2017-12-29 12:33:10 +08:00
harttle 900664a26d test cases for #53 2017-12-29 12:17:52 +08:00
harttle 757a06ee83 fix linting 2017-12-29 12:14:01 +08:00
harttle 9f6e9f2f3f 3.0.0 2017-12-23 21:36:37 +08:00
harttle 0f9adfb067 change: remove deprecated features, coverall 2017-12-23 21:31:55 +08:00
harttle dabde0e9e4 2.2.1 2017-12-23 13:01:28 +08:00
harttle bd4e851b3c update babelify 2017-12-23 12:57:19 +08:00
harttle 1d2aece687 2.2.0 2017-12-21 14:10:42 +08:00
harttle ace271c7f0 feature: support static filepath resolving by options.dynamicPartials,
fix #51
2017-12-21 14:09:30 +08:00
Sami KukkonenandJun Yang 4cbfa6d204 Ignore "fs" module in browser environments 2017-12-21 13:09:21 +08:00
harttle 3153f1d4bb 2.1.4 2017-12-10 01:35:21 +08:00
harttle 9cd4f3d904 modified: README.md 2017-12-10 01:35:06 +08:00
harttle 8dd1b3ba99 2.1.3 2017-12-10 01:26:46 +08:00
harttle 11de73a7b1 update doc 2017-12-10 00:30:13 +08:00
harttle 0325eacddf 2.1.2 2017-12-08 10:42:27 +08:00
harttle a21fcf6f87 fix: compatible to nodejs<=4 2017-12-08 10:42:00 +08:00
harttle 7bb2ee2213 2.1.1 2017-12-08 00:29:09 +08:00
harttle b24582c2c4 remove debug message, working on #50 2017-12-08 00:28:51 +08:00
harttle 49cb7a8c36 2.1.0 2017-12-08 00:25:44 +08:00
harttle a4126e7f10 fix: typo in scope.get("liquid") error message, fixes #50 2017-12-08 00:24:23 +08:00
harttle 5196d6ad56 feature: date filter supports utc string now, fixes #49 2017-12-08 00:22:56 +08:00
harttle 6082bf4757 2.0.3 2017-11-27 00:00:09 +08:00
harttle 8efb41a631 use isTruthy for and/or operators, fixes #47 2017-11-26 23:59:50 +08:00
harttle d348edac14 2.0.2 2017-11-06 00:16:51 +08:00
harttle be00f1d385 feature: treat top-level content as anonymous block, fixes #45 2017-11-06 00:14:33 +08:00
harttle 4e132ca1c5 tags: use scope.opts insteadof scope.get('liquid') 2017-11-04 10:46:15 +08:00
harttle 329aea6bd6 2.0.1 2017-10-31 00:11:35 +08:00
harttle 23e7424f9d change: default extname to "", working for #41 2017-10-31 00:10:45 +08:00
harttle 8241625be4 remove publish from version script 2017-10-30 02:24:08 +08:00
harttle d36ec17621 2.0.0 2017-10-30 02:23:36 +08:00
harttle 485424cc89 feature: concat filter 2017-10-30 02:22:56 +08:00
harttle a239389044 docs for #41 2017-10-30 02:07:07 +08:00
harttle e8fa8d32f5 feature: separate options for value/tag trimming, working on #17 2017-10-30 01:46:31 +08:00
harttle 502426f621 mv whiteSpaceCtrl to a separate file 2017-10-30 00:36:21 +08:00
harttle 8c77fc5a3d fix: whiteSpace Ctrl with compliance to shopify/liquid, working on #17 2017-10-30 00:09:29 +08:00
harttle be17d7443c 1.9.7 2017-10-21 10:50:44 +08:00
Mehdi JafferyandJun Yang 118624ca7d Fix to make for tag iterate objects like Shopify liquid.
Ref: https://github.com/Shopify/liquid/wiki/Liquid-for-Designers#allowed-collection-types
2017-10-18 05:41:43 -05:00
harttle d08ad6dc97 fix: error.stack assertion in v8.5 2017-10-06 12:32:06 +08:00
harttle e22870f5d7 fix: broken unit test by UTC time parsing behaviour change 2017-10-06 12:16:03 +08:00
harttle bd6706cf4d update outdated 2017-10-05 08:32:32 +08:00
harttle b71928ffd4 refactor: format 2017-10-05 08:21:32 +08:00
harttle 6f69cd774d 1.9.6 2017-09-15 10:39:18 +08:00
harttle 1b662d374d update outdated dependencies 2017-09-15 10:38:54 +08:00
harttle 6dd6ed176c 1.9.5 2017-08-26 17:58:14 +08:00
harttle 21af8c4d7a fix read/write variable in parent's scope, fix #39 2017-08-26 17:57:43 +08:00
harttle 942a3224a1 1.9.4 2017-08-16 00:07:47 +08:00
harttle 11259fae62 fix stack matching 2017-08-16 00:04:31 +08:00
harttle 030037eedc cover all 2017-08-15 23:52:05 +08:00
harttle 6d59f34fc8 cover all 2017-08-14 22:43:49 +08:00
harttle 72597c52e5 cover all 2017-08-14 22:07:08 +08:00
harttle 7904f823a8 1.9.3 2017-08-04 11:28:02 +08:00
harttle e993118e87 Merge branch 'jaswrks-patch-1' 2017-08-04 11:27:37 +08:00
harttle 4ae63b2899 test cases for #36 2017-08-04 11:27:12 +08:00
jaswrksandGitHub 9f446ad024 Support {{- and -}} for whitespace control.
With this PR it now matches the intended functionality; i.e., https://github.com/harttle/liquidjs/wiki/Whitespace-Control
2017-08-03 06:06:35 -08:00
harttle 6f82b914cb 1.9.2 2017-08-03 13:56:09 +08:00
harttle 31397a4862 update uglify-js 2017-08-03 13:55:46 +08:00
harttle a2a076d038 refactor access seq parsing 2017-08-03 13:46:00 +08:00
jaswrksandGitHub 3dc37bf980 Bug fix for foo.bar[0].foo that is not working.
Corrects a bug where `foo.bar[0].foo` results in error: 'Cannot read property `foo` of undefined', because the sequence contains an empty string; i.e., `seq.push('')` should be avoided.

Another possible solution would be to strip empty strings from the final `seq` variable, but this PR fixes the immediate problem.
2017-08-02 10:37:11 -08:00
harttle 4ee2bc964c upgrade outdated dependencies 2017-07-28 21:25:24 +08:00
wojtask9andJun Yang ea2a5f5c3b add identation value to token (#34)
* add identation value to token

* fix lint problems

* use var instead of let
2017-07-21 12:44:27 +08:00
harttle 52e2be68ab 1.9.1 2017-07-17 01:09:22 +08:00
harttle cbde48971a rename to liquidjs 2017-07-17 01:08:51 +08:00
harttle e91cc8c950 update: auto publish after version 2017-07-14 10:42:01 +08:00
289 changed files with 59393 additions and 7287 deletions
+4
View File
@@ -0,0 +1,4 @@
node_modules
dist
demo
coverage
+12 -1
View File
@@ -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 -34
View File
@@ -1,40 +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
.vscode
-1
View File
@@ -1 +0,0 @@
test/
+17 -5
View File
@@ -1,7 +1,19 @@
language: node_js
node_js:
- "5"
before_script:
- npm install -g mocha
after_script:
- NODE_ENV=test ./node_modules/.bin/istanbul cover --report lcovonly ./node_modules/mocha/bin/_mocha -- -R spec --recursive && 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
+32
View File
@@ -0,0 +1,32 @@
# [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))
+155 -110
View File
@@ -1,102 +1,101 @@
# shopify-liquid
# liquidjs
[![npm](https://img.shields.io/npm/v/shopify-liquid.svg)](https://www.npmjs.org/package/shopify-liquid)
[![Build Status](https://travis-ci.org/harttle/shopify-liquid.svg?branch=master)](https://travis-ci.org/harttle/shopify-liquid)
[![Coveralls](https://img.shields.io/coveralls/harttle/shopify-liquid.svg)](https://coveralls.io/github/harttle/shopify-liquid?branch=master)
[![GitHub issues](https://img.shields.io/github/issues-closed/harttle/shopify-liquid.svg)](https://github.com/harttle/shopify-liquid/issues)
[![npm](https://img.shields.io/npm/v/liquidjs.svg)](https://www.npmjs.org/package/liquidjs)
[![npm](https://img.shields.io/npm/dm/liquidjs.svg)](https://www.npmjs.org/package/liquidjs)
[![Build Status](https://travis-ci.org/harttle/liquidjs.svg?branch=master)](https://travis-ci.org/harttle/liquidjs)
[![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/liquidjs.svg)](https://github.com/harttle/liquidjs/issues)
[![GitHub contributors](https://img.shields.io/github/contributors/harttle/liquidjs.svg)](https://github.com/harttle/liquidjs/graphs/contributors)
[![David](https://img.shields.io/david/harttle/liquidjs.svg)](https://david-dm.org/harttle/liquidjs)
[![David Dev](https://img.shields.io/david/dev/harttle/liquidjs.svg)](https://david-dm.org/harttle/liquidjs?type=dev)
[![DUB](https://img.shields.io/dub/l/vibe-d.svg)](https://github.com/harttle/liquidjs/blob/master/LICENSE)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://github.com/harttle/liquidjs)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/harttle/liquidjs)
A Liquid template engine with a wide range of tags and filters,
for both Node.js and browsers.
Here's a live demo: <http://harttle.com/shopify-liquid/>
This is a liquid implementation for both Node.js and browsers. Website: <http://harttle.github.io/liquidjs/>, Live Demo: <https://jsfiddle.net/6u40xbzs/>
> The Liquid template engine is implemented in Ruby originally,
> which is used by [Jekyll][jekyll] and [Github Pages][gh].
**Features**
Features:
* Fully compatible to [shopify][shopify/liquid], with all [tags][tags] and [filters][filters] implemented
* Support layout(extend) and include syntax
* In pure JavaScript with Promise-based API
* 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)
* Easy tag/filter registration, allows async tags
* [any-promise][any-promise]
**Differences**
API Reference:
Though being compatible with [Ruby Liquid](https://github.com/shopify/liquid) is one of our priorities, there're still certain differences. You may need some configuration to get it compatible in these senarios:
* Builtin Tags: <https://github.com/harttle/shopify-liquid/wiki/Builtin-Tags>
* Builtin Filters: <https://github.com/harttle/shopify-liquid/wiki/Builtin-Filters>
* Operators: <https://github.com/harttle/shopify-liquid/wiki/Operators>
* Whitespace Control: <https://github.com/harttle/shopify-liquid/wiki/Whitespace-Control>
* 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 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.
Installation:
## TOC
```bash
npm install --save shopify-liquid
```
* Usage
* [Render from String](#render-from-string)
* [Render from File](#render-from-file)
* [Use with Express.js](#use-with-expressjs)
* [Use in Browser](#use-in-browser)
* [Include Partials](#include-partials)
* [Layout Templates (Extends)](#layout-templates-extends)
* API Spec
* [Constructor Options](#options)
* [Register Filters](#register-filters), [Builtin Filters](https://github.com/harttle/liquidjs/wiki/Builtin-Filters)
* [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
```
Parse and Render:
```javascript
var Liquid = require('shopify-liquid');
var engine = Liquid();
var Liquid = require('liquidjs');
var engine = new Liquid();
engine.parseAndRender('{{name | capitalize}}', {name: 'alice'})
.then(function(html){
// html === 'Alice'
});
engine
.parseAndRender('{{name | capitalize}}', {name: 'alice'})
.then(console.log);
// outputs 'Alice'
```
Caching templates:
```javascript
var tpl = engine.parse('{{name | capitalize}}');
engine.render(tpl, {name: 'alice'})
.then(function(html){
// html === 'Alice'
});
engine
.render(tpl, {name: 'alice'})
.then(console.log);
// outputs 'Alice'
```
## Render from File
```javascript
var engine = Liquid({
var engine = new Liquid({
root: path.resolve(__dirname, 'views/'), // dirs to lookup layouts/includes
extname: '.liquid' // the default extname used for layouts/includes
extname: '.liquid' // the extname used for layouts/includes, defaults ""
});
engine.renderFile("hello.liquid", {name: 'alice'})
.then(function(html){
// html === 'Alice'
});
// equivalent to:
engine.renderFile("hello", {name: 'alice'})
.then(function(html){
// html === 'Alice'
});
.then(console.log) // outputs "Alice"
// which is equivalent to:
engine
.renderFile("hello", {name: 'alice'})
.then(console.log) // outputs "Alice"
```
## Options
The full list of options for `Liquid()` is listed as following:
* `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 `["."]`
* `extname` is used to lookup the template file when filepath doesn't include an extension name. Defaults to `".liquid"`
* `cache` indicates whether or not to cache resolved templates. Defaults to `false`.
* `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_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`.
* `trim_right` is used to strip blank characters (including ` `, `\t`, and `\r`) from the right of tags (`{% %}`) until `\n` (inclusive). Defaults to `false`.
* `trim_left` is similiar to `trim_right`, whereas the `\n` is exclusive. Defaults to `false`. See [Whitespace Control][whitespace control] for details.
* `greedy` is used to specify whether `trim_left`/`trim_right` is greedy. When set to `true`, all successive blank characters including `\n` will be trimed regardless of line breaks. Defaults to `false`.
## Use with Express.js
```javascript
@@ -106,41 +105,25 @@ app.set('views', './views'); // specify the views directory
app.set('view engine', 'liquid'); // set to default
```
> There's an Express demo [here](demo/express/).
When using with Express.js, partials(includes and layouts) will be looked up in
both Liquid `root` and Express `views` directories.
[Here](demo/express/)'s an Express demo. When used with Express.js,
Express [`views`][express-views] will be included when looking up
partials(includes and layouts).
## Use in Browser
[Download][releases] the dist files and import into your HTML.
And `window.Liquid` is what you want. There's also a [demo](demo/browser/).
You can get a dist file for browsers from
```html
<html lang="en">
<head>
<script src="dist/liquid.min.js"></script>
</head>
<body>
<script>
var engine = window.Liquid();
var src = '{{ name | capitalize}}';
var ctx = {
name: 'welcome to Shopify Liquid'
};
engine.parseAndRender(src, ctx)
.then(function(html) {
// html === Welcome to Shopify Liquid
});
</script>
</body>
</html>
```
* [Releases][releases] page for liquidjs, or
* unpkg.com: <https://unpkg.com/liquidjs/dist/liquid.min.js>
Note: In [IE and Android UC][caniuse-promises] browser, you need a Promise implementation
registered to [any-promise][any-promise].
Here's the demo:
## Includes
* JSFiddle: <https://jsfiddle.net/6u40xbzs/>
* Demo directory: [/demo/browser/](demo/browser/).
Note: For [IE and Android UC][caniuse-promises] browser, you will need a [Promise polyfill][pp].
## Include Partials
```
// file: color.liquid
@@ -161,7 +144,7 @@ color: 'red' shape: 'circle'
color: 'yellow' shape: 'square'
```
## Layouts
## Layout Templates (Extends)
```
// file: default-layout.liquid
@@ -185,16 +168,51 @@ Footer
* It's possible to define multiple blocks.
* block name is optional when there's only one block.
## Options
The full list of options for `Liquid()` is listed as following:
* `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 `["."]`
* `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 `""`.
* `cache` indicates whether or not to cache resolved templates. Defaults to `false`.
* `dynamicPartials`: if set, treat `<filepath>` parameter in `{%include filepath %}`, `{%layout filepath%}` as a variable, otherwise as a literal value. Defaults to `true`.
* `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_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`.
* `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_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_value_left` is similiar to `trim_value_right`, whereas the `\n` is exclusive. Defaults to `false`. See [Whitespace Control][whitespace control] for details.
* `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`.
## Register Filters
```javascript
// Usage: {{ name | uppper }}
engine.registerFilter('upper', function(v){
return v.toUpperCase();
});
engine.registerFilter('upper', v => v.toUpperCase())
```
> See existing filter implementations: <https://github.com/harttle/shopify-liquid/blob/master/filters.js>
Filter arguments will be passed to the registered filter function, for example:
```javascript
// Usage: {{ 1 | add: 2, 3 }}
engine.registerFilter('add', (initial, arg1, arg2) => initial + arg1 + arg2)
```
See existing filter implementations here: <https://github.com/harttle/liquidjs/tree/master/src/builtin/filters>
## Register Tags
@@ -211,21 +229,48 @@ engine.registerTag('upper', {
});
```
> See existing tag implementations: <https://github.com/harttle/shopify-liquid/blob/master/tags/>
* `parse`: Read tokens from `remainTokens` until your end token.
* `render`: Combine scope data with your parsed tokens into HTML string.
## Contribution Guide
See existing tag implementations here: <https://github.com/harttle/liquidjs/tree/master/src/builtin/tags>
1. Write a [test][test] to define the feature you want.
2. File an issue, or optionally:
3. Get your test pass and make a pull request.
## 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
[shopify-liquid]: https://shopify.github.io/liquid/
[shopify/liquid]: https://shopify.github.io/liquid/
[jekyll]: http://jekyllrb.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
[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
[whitespace control]: https://github.com/harttle/shopify-liquid/wiki/Whitespace-Control
[whitespace control]: https://github.com/harttle/liquidjs/wiki/Whitespace-Control
[tags]: https://github.com/harttle/liquidjs/wiki/Builtin-Tags
[filters]: https://github.com/harttle/liquidjs/wiki/Builtin-Filters
[express-views]: http://expressjs.com/en/guide/using-template-engines.html
[pp]: https://github.com/taylorhakes/promise-polyfill
+1
View File
@@ -0,0 +1 @@
access time: {{date|date: "%Y-%m-%d %H:%M:%S"}}
+1
View File
@@ -0,0 +1 @@
<h2>Welcome to {{ name | capitalize}}, {% include 'date.html' %}</h2>
+13 -10
View File
@@ -1,26 +1,29 @@
<!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>
<h2 id="header"></h2>
<script>
var engine = window.Liquid();
var src = 'Welcome to {{ name | capitalize}}, ' +
'access time: {{date|date: "%Y-%m-%d %H:%M:%S"}}';
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"}}&lt;/h2>';
var ctx = {
name: 'Liquid',
date: new Date()
};
engine.parseAndRender(src, ctx)
.then(function(html) {
document.getElementById('header').innerHTML = html;
return engine.renderFile('hello', ctx);
})
.then(function(html) {
document.body.innerHTML += html
});
</script>
</body>
+220
View File
@@ -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
}
}
}
+17
View File
@@ -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"
}
}
+17 -17
View File
@@ -1,22 +1,22 @@
var express = require('express');
var app = express();
var Liquid = require('../..');
const express = require('express')
const Liquid = require('../..')
var engine = Liquid({
root: __dirname, // for layouts and partials
extname: '.liquid'
});
const app = express()
const engine = new Liquid({
root: __dirname, // for layouts and partials
extname: '.liquid'
})
app.engine('liquid', engine.express()); // register liquid engine
app.set('views', ['./partials', './views']); // specify the views directory
app.set('view engine', 'liquid'); // set to default
app.engine('liquid', engine.express()) // register liquid engine
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'];
res.render('todolist', {
todos: todos,
title: 'Welcome to shopify-liquid!'
});
});
const todos = ['fork and clone', 'make it better', 'make a pull request']
res.render('todolist', {
todos: todos,
title: 'Welcome to liquidjs!'
})
})
module.exports = app;
module.exports = app
+3 -4
View File
@@ -1,6 +1,5 @@
const app = require('./app.js');
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 -2
View File
@@ -1,14 +1,14 @@
{
"name": "express-demo",
"version": "1.0.0",
"description": "Express Demo Using Shopify-Liquid",
"description": "Express Demo Using liquidjs",
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "harttle",
"license": "ISC",
"license": "MIT",
"dependencies": {
"express": "^4.14.0"
}
+2 -2
View File
@@ -1,8 +1,8 @@
{% layout 'layout' %}
<ul>
{% for todo in todolist %}
<li>{% include 'todo' id=forloop.index %}</li>
{% for todo in todos %}
<li>{% include 'todo', id:forloop.index %}</li>
{% endfor %}
</ul>
+26
View File
@@ -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))
+12
View File
@@ -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=="
}
}
}
+11
View File
@@ -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"
}
}
+7
View File
@@ -0,0 +1,7 @@
{%header content: "welcome to liquid" | capitalize%}
<ul>
{% for todo in todos %}
<li>{{forloop.index}} - {{todo}}</li>
{% endfor %}
</ul>
+21
View File
@@ -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
+16737
View File
File diff suppressed because it is too large Load Diff
+30
View File
@@ -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

+41
View File
@@ -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>
+15
View File
@@ -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"
}
+32
View File
@@ -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);
}
}
+46
View File
@@ -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;
+9
View File
@@ -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);
});
+14
View File
@@ -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;
}
+12
View File
@@ -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();
+7
View File
@@ -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

+127
View File
@@ -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();
});
}
}
+18
View File
@@ -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
+25
View File
@@ -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)
+8701
View File
File diff suppressed because it is too large Load Diff
+14
View File
@@ -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"
}
}
+7
View File
@@ -0,0 +1,7 @@
{%header content: "welcome to liquid" | capitalize%}
<ul>
{% for todo in todos %}
<li>{{forloop.index}} - {{todo}}</li>
{% endfor %}
</ul>
View File
+12
View File
@@ -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;
+4
View File
@@ -0,0 +1,4 @@
declare const _default: {
'date': (v: any, arg: any) => any;
};
export default _default;
+8
View File
@@ -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;
+46
View File
@@ -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;
+12
View File
@@ -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;
+4
View File
@@ -0,0 +1,4 @@
declare const _default: {
'default': (v: any, arg: any) => any;
};
export default _default;
+20
View File
@@ -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;
+5
View File
@@ -0,0 +1,5 @@
declare const _default: {
'url_decode': (x: any) => any;
'url_encode': (x: any) => any;
};
export default _default;
+5
View File
@@ -0,0 +1,5 @@
declare const _default: {
parse: (token: any) => void;
render: (scope: any) => Promise<string>;
};
export default _default;
+5
View File
@@ -0,0 +1,5 @@
declare const _default: {
parse: (token: any, remainTokens: any) => void;
render: (scope: any) => Promise<any>;
};
export default _default;
+4
View File
@@ -0,0 +1,4 @@
declare const _default: {
render: () => Promise<never>;
};
export default _default;
+8
View File
@@ -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;
+5
View File
@@ -0,0 +1,5 @@
declare const _default: {
parse: (tagToken: any, remainTokens: any) => void;
render: (scope: any) => any;
};
export default _default;
+4
View File
@@ -0,0 +1,4 @@
declare const _default: {
parse: (tagToken: any, remainTokens: any) => void;
};
export default _default;
+4
View File
@@ -0,0 +1,4 @@
declare const _default: {
render: () => Promise<never>;
};
export default _default;
+5
View File
@@ -0,0 +1,5 @@
declare const _default: {
parse: (tagToken: any) => void;
render: (scope: any) => any;
};
export default _default;
+7
View File
@@ -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;
+7
View File
@@ -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;
+5
View File
@@ -0,0 +1,5 @@
declare const _default: {
parse: (tagToken: any, remainTokens: any) => void;
render: (scope: any) => any;
};
export default _default;
+5
View File
@@ -0,0 +1,5 @@
declare const _default: {
parse: (token: any) => void;
render: (scope: any, hash: any) => Promise<any>;
};
export default _default;
+5
View File
@@ -0,0 +1,5 @@
declare const _default: {
parse: (token: any) => void;
render: (scope: any) => any;
};
export default _default;
+5
View File
@@ -0,0 +1,5 @@
import ITagImplOptions from 'src/template/tag/itag-impl-options';
declare const tags: {
[key: string]: ITagImplOptions;
};
export default tags;
+5
View File
@@ -0,0 +1,5 @@
declare const _default: {
parse: (token: any, remainTokens: any) => void;
render: (scope: any, hash: any) => Promise<any>;
};
export default _default;
+5
View File
@@ -0,0 +1,5 @@
declare const _default: {
parse: (tagToken: any, remainTokens: any) => void;
render: () => any;
};
export default _default;
+5
View File
@@ -0,0 +1,5 @@
declare const _default: {
parse: (tagToken: any, remainTokens: any) => void;
render: (scope: any, hash: any) => Promise<string>;
};
export default _default;
+5
View File
@@ -0,0 +1,5 @@
declare const _default: {
parse: (tagToken: any, remainTokens: any) => void;
render: (scope: any) => any;
};
export default _default;
+3
View File
@@ -0,0 +1,3 @@
import IFS from './ifs';
declare const _default: IFS;
export default _default;
+5
View File
@@ -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;
}
+3
View File
@@ -0,0 +1,3 @@
import IFS from './ifs';
declare const fs: IFS;
export default fs;
+29
View File
@@ -0,0 +1,29 @@
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_value_right` is used to strip blank characters (including ` `, `\t`, and `\r`) from the right of values (`{{ }}`) until `\n` (inclusive). Defaults to `false`. */
trim_value_right?: boolean;
/** `trim_value_left` is similar to `trim_value_right`, whereas the `\n` is exclusive. Defaults to `false`. See Whitespace Control for details. */
trim_value_left?: boolean;
/** `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 declare const defaultOptions: NormalizedOptions;
export declare function normalize(options: LiquidOptions): NormalizedOptions;
+2259
View File
File diff suppressed because it is too large Load Diff
+1
View File
File diff suppressed because one or more lines are too long
+30
View File
@@ -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, NormalizedOptions } from './liquid-options';
export default class Liquid {
options: NormalizedOptions;
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;
}
+2241 -2503
View File
File diff suppressed because it is too large Load Diff
+1
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
File diff suppressed because one or more lines are too long
+1
View File
File diff suppressed because one or more lines are too long
+6
View File
@@ -0,0 +1,6 @@
import Token from './token';
export default class DelimitedToken extends Token {
trimLeft: boolean;
trimRight: boolean;
constructor(raw: any, pos: any, input: any, file: any, line: any);
}
+4
View File
@@ -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);
}
+35
View File
@@ -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;
+4
View File
@@ -0,0 +1,4 @@
import DelimitedToken from './delimited-token';
export default class OutputToken extends DelimitedToken {
constructor(raw: any, pos: any, input: any, file: any, line: any);
}
+16
View File
@@ -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 {};
+13
View File
@@ -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;
}
+6
View File
@@ -0,0 +1,6 @@
import DelimitedToken from './delimited-token';
export default class TagToken extends DelimitedToken {
name: string;
args: string;
constructor(raw: any, pos: any, input: any, file: any, line: any);
}
+9
View File
@@ -0,0 +1,9 @@
export default class Token {
type: string;
line: number;
raw: string;
input: string;
file: string;
value: string;
constructor(raw: any, pos: any, input: any, file: any, line: any);
}
+6
View File
@@ -0,0 +1,6 @@
import { LiquidOptions } from 'src/liquid-options';
export default class Tokenizer {
options: LiquidOptions;
constructor(options?: LiquidOptions);
tokenize(input: string, file?: string): any[];
}
+3
View File
@@ -0,0 +1,3 @@
import Token from 'src/parser/token';
import { LiquidOptions } from 'src/liquid-options';
export default function whiteSpaceCtrl(tokens: Token[], options: LiquidOptions): void;
+3
View File
@@ -0,0 +1,3 @@
export default class Render {
renderTemplates(templates: any, scope: any): Promise<string>;
}
+4
View File
@@ -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;
+5
View File
@@ -0,0 +1,5 @@
declare enum BlockMode {
OUTPUT = 0,
STORE = 1
}
export default BlockMode;
+18
View File
@@ -0,0 +1,18 @@
import { NormalizedOptions } from '../liquid-options';
import BlockMode from './block-mode';
export default class Scope {
opts: NormalizedOptions;
contexts: Array<object>;
blocks: object;
blockMode: BlockMode;
constructor(ctx?: object, opts?: NormalizedOptions);
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[];
}
+8
View File
@@ -0,0 +1,8 @@
export declare class CaptureScope {
}
export declare class AssignScope {
}
export declare class IncrementScope {
}
export declare class DecrementScope {
}
+14
View File
@@ -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 {};
+8
View File
@@ -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>;
}
+6
View File
@@ -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>;
}
+10
View File
@@ -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>;
}
+10
View File
@@ -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
View File
@@ -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>;
}
+5
View File
@@ -0,0 +1,5 @@
import Liquid from 'src/liquid';
import ITagImplOptions from './itag-impl-options';
export default interface ITagImpl extends ITagImplOptions {
liquid: Liquid;
}

Some files were not shown because too many files have changed in this diff Show More