Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mozilla/nunjucks
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b045b8759988eea7a2d2f0ffbd86c67cddeca527
Choose a base ref
...
head repository: mozilla/nunjucks
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 86a77f49da4779d55414d8337e1a4d7ec7582da5
Choose a head ref
Loading
Showing with 16,875 additions and 40,028 deletions.
  1. +19 −0 .babelrc
  2. 0 .jshintignore → .eslintignore
  3. +52 −0 .eslintrc.js
  4. +6 −0 .gitattributes
  5. +23 −0 .github/PULL_REQUEST_TEMPLATE.md
  6. +43 −0 .github/workflows/tests.yml
  7. +10 −1 .gitignore
  8. +0 −31 .jshintrc
  9. +3 −0 .npmignore
  10. +0 −8 .travis.yml
  11. +241 −1 CHANGELOG.md
  12. +15 −0 CODE_OF_CONDUCT.md
  13. +40 −17 CONTRIBUTING.md
  14. +29 −6 README.md
  15. +5 −6 appveyor.yml
  16. +0 −8 bin/bundle
  17. +0 −88 bin/bundle.js
  18. +43 −55 bin/precompile
  19. +3 −2 bower.json
  20. +0 −2,678 browser/nunjucks-slim.js
  21. +0 −2 browser/nunjucks-slim.min.js
  22. +0 −6,330 browser/nunjucks.js
  23. +0 −4 browser/nunjucks.min.js
  24. +2 −0 codecov.yml
  25. +2 −2 docs/README.md
  26. +2 −1 docs/_config.yml
  27. +3 −1 docs/_layouts/page.html
  28. +60 −13 docs/api.md
  29. +12 −12 docs/cn/api.md
  30. +2 −2 docs/cn/getting-started.md
  31. +67 −27 docs/cn/templating.md
  32. +10 −1 docs/css/app.css
  33. +12 −2 docs/faq.md
  34. +45 −8 docs/fr/api.md
  35. +2 −1 docs/fr/faq.md
  36. +16 −12 docs/fr/getting-started.md
  37. +1,074 −113 docs/fr/templating.md
  38. +22 −0 docs/getting-started.md
  39. BIN docs/img/favicon.png
  40. +1 −30 docs/index.html
  41. +1,115 −76 docs/templating.md
  42. +0 −86 index.js
  43. +88 −0 nunjucks/index.js
  44. +1,200 −0 nunjucks/src/compiler.js
  45. +590 −0 nunjucks/src/environment.js
  46. +24 −0 nunjucks/src/express-app.js
  47. +648 −0 nunjucks/src/filters.js
  48. +73 −0 nunjucks/src/globals.js
  49. +305 −0 nunjucks/src/jinja-compat.js
  50. +539 −0 nunjucks/src/lexer.js
  51. +396 −0 nunjucks/src/lib.js
  52. +14 −0 nunjucks/src/loader.js
  53. 0 { → nunjucks}/src/loaders.js
  54. +150 −0 nunjucks/src/node-loaders.js
  55. +270 −0 nunjucks/src/nodes.js
  56. +85 −0 nunjucks/src/object.js
  57. +1,368 −0 nunjucks/src/parser.js
  58. +24 −0 nunjucks/src/precompile-global.js
  59. +134 −0 nunjucks/src/precompile.js
  60. +27 −0 nunjucks/src/precompiled-loader.js
  61. +380 −0 nunjucks/src/runtime.js
  62. +290 −0 nunjucks/src/tests.js
  63. +217 −0 nunjucks/src/transformer.js
  64. +95 −0 nunjucks/src/web-loaders.js
  65. +79 −14 package.json
  66. +3 −1 {tests/express-sample → samples/express}/js/app.js
  67. +48 −0 samples/express/js/extensions.js
  68. +37 −0 samples/express/main.js
  69. +28 −0 samples/express/pre.js
  70. +1 −1 {tests/express-sample → samples/express}/views/about.html
  71. 0 {tests/express-sample → samples/express}/views/base.html
  72. 0 {tests/express-sample → samples/express}/views/import-context-set.html
  73. +7 −0 samples/express/views/index.html
  74. 0 {tests/express-sample → samples/express}/views/item-base.html
  75. +1 −1 {tests/express-sample → samples/express}/views/item.html
  76. 0 {tests/express-sample → samples/express}/views/set.html
  77. +136 −0 scripts/bundle.js
  78. +17 −0 scripts/lib/arrow-function-coverage-fix.js
  79. +10 −0 scripts/lib/is-main-module.js
  80. +57 −0 scripts/lib/mocha-phantomjs.js
  81. +21 −0 scripts/lib/precompile.js
  82. +89 −0 scripts/lib/runtests.js
  83. +27 −0 scripts/lib/static-server.js
  84. +40 −0 scripts/lib/utils.js
  85. +36 −0 scripts/testrunner.js
  86. +0 −1,179 src/compiler.js
  87. +0 −589 src/environment.js
  88. +0 −577 src/filters.js
  89. +0 −79 src/globals.js
  90. +0 −156 src/jinja-compat.js
  91. +0 −514 src/lexer.js
  92. +0 −299 src/lib.js
  93. +0 −33 src/loader.js
  94. +0 −85 src/node-loaders.js
  95. +0 −303 src/nodes.js
  96. +0 −64 src/object.js
  97. +0 −1,284 src/parser.js
  98. +0 −24 src/precompile-global.js
  99. +0 −137 src/precompile.js
  100. +0 −22 src/precompiled-loader.js
  101. +0 −362 src/runtime.js
  102. +0 −239 src/transformer.js
  103. +0 −96 src/web-loaders.js
  104. +23 −0 tests/.eslintrc.js
  105. +93 −52 tests/api.js
  106. +0 −1,284 tests/browser/expect.js
  107. +17 −4 tests/browser/index.html
  108. +0 −246 tests/browser/mocha.css
  109. +0 −12,417 tests/browser/mocha.js
  110. +65 −0 tests/browser/slim.html
  111. +48 −0 tests/cli.js
  112. +2,134 −1,297 tests/compiler.js
  113. +76 −0 tests/core.js
  114. +0 −49 tests/express-sample/js/extensions.js
  115. +0 −4,913 tests/express-sample/js/nunjucks-dev.js
  116. +0 −1 tests/express-sample/js/nunjucks-min.js
  117. +0 −1,742 tests/express-sample/js/nunjucks.js
  118. +0 −36 tests/express-sample/js/require.js
  119. +0 −107 tests/express-sample/js/templates.js
  120. +0 −26 tests/express-sample/main.js
  121. +0 −16 tests/express-sample/pre.js
  122. +0 −7 tests/express-sample/views/index.html
  123. +45 −0 tests/express.js
  124. +0 −37 tests/express/express.js
  125. +1,008 −569 tests/filters.js
  126. +150 −141 tests/globals.js
  127. +126 −0 tests/jinja-compat.js
  128. +705 −369 tests/lexer.js
  129. +142 −59 tests/loader.js
  130. +925 −775 tests/parser.js
  131. +50 −19 tests/precompile.js
  132. +114 −64 tests/runtime.js
  133. +2 −0 tests/setup.js
  134. 0 tests/templates/{async.j2 → async.njk}
  135. +1 −1 tests/templates/{base-inherit.j2 → base-inherit.njk}
  136. +1 −1 tests/templates/{base-set-outside-block.j2 → base-set-and-show.njk}
  137. +1 −0 tests/templates/base-set-inside-block.njk
  138. 0 tests/templates/{base-set-wraps-block.j2 → base-set-wraps-block.njk}
  139. +1 −0 tests/templates/base-set.njk
  140. +1 −0 tests/templates/base-show.njk
  141. 0 tests/templates/{base.j2 → base.njk}
  142. 0 tests/templates/{base2.j2 → base2.njk}
  143. 0 tests/templates/{base3.j2 → base3.njk}
  144. +3 −0 tests/templates/broken-conditional-include.njk
  145. +2 −0 tests/templates/broken-import.njk
  146. 0 tests/templates/{for-async-content.j2 → for-async-content.njk}
  147. 0 tests/templates/{import-context-set.j2 → import-context-set.njk}
  148. 0 tests/templates/{import-context.j2 → import-context.njk}
  149. +1 −1 tests/templates/{import-macro-call-undefined-macro.j2 → import-macro-call-undefined-macro.njk}
  150. 0 tests/templates/{import.j2 → import.njk}
  151. 0 tests/templates/{include-in-loop.j2 → include-in-loop.njk}
  152. 0 tests/templates/{include-set.j2 → include-set.njk}
  153. 0 tests/templates/{include.j2 → include.njk}
  154. +130 −0 tests/templates/includeMany.njk
  155. 0 tests/templates/{item.j2 → item.njk}
  156. +1 −1 tests/templates/{macro-call-undefined-macro.j2 → macro-call-undefined-macro.njk}
  157. +0 −1 tests/templates/relative/dir1/index.j2
  158. +1 −0 tests/templates/relative/dir1/index.njk
  159. 0 tests/templates/relative/dir1/{macros.j2 → macros.njk}
  160. +0 −1 tests/templates/relative/dir2/index.j2
  161. +1 −0 tests/templates/relative/dir2/index.njk
  162. 0 tests/templates/relative/dir2/{macros.j2 → macros.njk}
  163. +0 −2 tests/templates/relative/test-cache.j2
  164. +2 −0 tests/templates/relative/test-cache.njk
  165. +1 −1 tests/templates/relative/{test1.j2 → test1.njk}
  166. +1 −1 tests/templates/relative/{test2.j2 → test2.njk}
  167. 0 tests/templates/{set.j2 → set.njk}
  168. 0 tests/templates/{simple-base.j2 → simple-base.njk}
  169. +1 −0 tests/templates/throws.njk
  170. 0 tests/templates/{undefined-macro.j2 → undefined-macro.njk}
  171. 0 tests/test-node-pkgs/dummy-pkg/index.js
  172. +12 −0 tests/test-node-pkgs/dummy-pkg/package.json
  173. +1 −0 tests/test-node-pkgs/dummy-pkg/simple-template.html
  174. +260 −0 tests/tests.js
  175. +197 −105 tests/util.js
19 changes: 19 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"presets": [
["@babel/env", {
"loose": true,
"targets": {
"browsers": ["last 2 versions", "safari >= 7", "ie 9"],
"node": "6"
}
}]
],
"env": {
"test": {
"plugins": ["./scripts/lib/arrow-function-coverage-fix", "istanbul"]
}
},
"ignore": [
"scripts/lib/arrow-function-coverage-fix.js"
]
}
File renamed without changes.
52 changes: 52 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
module.exports = {
'extends': [
'airbnb-base/legacy',
],
'parserOptions': {
'sourceType': 'module',
'ecmaVersion': 2017,
},
'env': {
'node': true,
'es6': true,
},
"rules": {
// The one assertion of personal preference: no spaces before parentheses
// of anonymous functions
'space-before-function-paren': ['error', {
anonymous: 'never',
named: 'never',
asyncArrow: 'always',
}],
// Temporarily disabled rules
//
// no-use-before-define is a good rule, but it would make the diff for
// linting the code even more inscrutible than it already is.
'no-use-before-define': 'off',
// Relax some rules
'no-cond-assign': ['error', 'except-parens'],
'no-unused-vars': ['error', {
'args': 'none',
}],
// Disable some overly-strict airbnb style rules
'no-underscore-dangle': 'off',
'no-param-reassign': 'off',
'class-methods-use-this': 'off',
'function-paren-newline': 'off',
'no-plusplus': 'off',
'object-curly-spacing': 'off',
'no-multi-assign': 'off',
'no-else-return': 'off',
// While technically useless from the point of view of the regex parser,
// escaping characters inside character classes is more consistent. I
// would say that they make the regular expression more readable, if the
// idea of readable regular expressions wasn't absurd on its face.
'no-useless-escape': 'off',
// I'm inclined to reverse this rule to be ['error', 'always'], but not just yet
// IE 8 is a thing of the past and trailing commas are useful.
'comma-dangle': 'off',
},
'globals': {
'nunjucks': false,
},
};
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Checkout example and test fixtures with linux line ending
# to guarantee test successes
tests/** text eol=lf
23 changes: 23 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Summary

Proposed change:

<!--
Please replace this with a human-friendly description of your proposed change.
* If you have multiple changes, try to split them into separate PRs.
* If this change closes an issue, please write "Closes #{number}".
-->

Closes # .


## Checklist

I've completed the checklist below to ensure I didn't forget anything. This makes reviewing this PR as easy as possible for the maintainers. And it gets this change released as soon as possible.

* [ ] Proposed change helps towards [*purpose of this project*](https://github.com/mozilla/nunjucks/blob/master/CONTRIBUTING.md#purpose).
* [ ] [*Documentation*](https://github.com/mozilla/nunjucks/tree/master/docs/) is added / updated to describe proposed change.
* [ ] [*Tests*](https://github.com/mozilla/nunjucks/tree/master/tests) are added / updated to cover proposed change.
* [ ] [*Changelog*](https://github.com/mozilla/nunjucks/blob/master/CHANGELOG.md) has an entry for proposed change (if user-facing fix or feature).

<!-- Tick of items by replacing `[ ]` by `[x]` -->
43 changes: 43 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Tests

on:
push:
branches:
- '**'
pull_request:
branches:
- master
paths:
- '**/*.js'
- 'package.json'
- '**/*.njk'
- '**/*.yml'
- 'tests/**/*.html'

jobs:
tests:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
node-version: [11.x, 10.x, 8.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v2
id: cache-node-modules
with:
path: node_modules
key: ${{ matrix.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package.json') }}
- run: npm install
if: steps.cache-node-modules.outputs.cache-hit != 'true'
- run: npm test
# Commented out until this action is added in organization settings
# - name: Report coverage
# if: success()
# uses: codecov/codecov-action@v1
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -2,4 +2,13 @@ node_modules
coverage
.#*
docs/_site
docs/files
docs/files
/src/
/index.js
/index.js.map
/tests/browser/nunjucks*
.nyc_output
/browser
/tests/browser/precompiled-templates.js
/samples/express/js/nunjucks.js
/samples/express/js/templates.js
31 changes: 0 additions & 31 deletions .jshintrc

This file was deleted.

3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
node_modules
coverage
.nyc_output
docs
tests
bench
nunjucks
scripts
8 changes: 0 additions & 8 deletions .travis.yml

This file was deleted.

Loading