-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
119 changed files
with
10,834 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_size = 2 | ||
indent_style = space | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.edge] | ||
insert_final_newline = false | ||
trim_trailing_whitespace=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
coverage | ||
node_modules | ||
.DS_Store | ||
npm-debug.log | ||
.idea | ||
dump.rdb | ||
test/unit/storage/sessions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
coverage | ||
node_modules | ||
.DS_Store | ||
npm-debug.log | ||
test | ||
dump.rdb | ||
.travis.yml | ||
.editorconfig | ||
benchmarks | ||
.idea | ||
bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
language: node_js | ||
node_js: | ||
- node | ||
- 7.0.0 | ||
- 6.0.0 | ||
sudo: false | ||
install: | ||
- npm install | ||
notifications: | ||
slack: | ||
secure: m91zkX2cLVDRDMBAUnR1d+hbZqtSHXLkuPencHadhJ3C3wm53Box8U25co/goAmjnW5HNJ1SMSIg+DojtgDhqTbReSh5gSbU0uU8YaF8smbvmUv3b2Q8PRCA7f6hQiea+a8+jAb7BOvwh66dV4Al/1DJ2b4tCjPuVuxQ96Wll7Pnj1S7yW/Hb8fQlr9wc+INXUZOe8erFin+508r5h1L4Xv0N5ZmNw+Gqvn2kPJD8f/YBPpx0AeZdDssTL0IOcol1+cDtDzMw5PAkGnqwamtxhnsw+i8OW4avFt1GrRNlz3eci5Cb3NQGjHxJf+JIALvBeSqkOEFJIFGqwAXMctJ9q8/7XyXk7jVFUg5+0Z74HIkBwdtLwi/BTyXMZAgsnDjndmR9HsuBP7OSTJF5/V7HCJZAaO9shEgS8DwR78owv9Fr5er5m9IMI+EgSH3qtb8iuuQaPtflbk+cPD3nmYbDqmPwkSCXcXRfq3IxdcV9hkiaAw52AIqqhnAXJWZfL6+Ct32i2mtSaov9FYtp/G0xb4tjrUAsDUd/AGmMJNEBVoHtP7mKjrVQ35cEtFwJr/8SmZxGvOaJXPaLs43dhXKa2tAGl11wF02d+Rz1HhbOoq9pJvJuqkLAVvRdBHUJrB4/hnTta5B0W5pe3mIgLw3AmOpk+s/H4hAP4Hp0gOWlPA= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<a name="1.0.0"></a> | ||
# 1.0.0 (2017-03-30) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* **tags:** allow nested each loops ([47ebd9c](https://github.com/poppinss/edge/commit/47ebd9c)) | ||
|
||
|
||
### Features | ||
|
||
* **ast:** add support for inline & block comments ([cb06a6b](https://github.com/poppinss/edge/commit/cb06a6b)) | ||
* **ast:** add support for self closing tags ([016bf48](https://github.com/poppinss/edge/commit/016bf48)) | ||
* **cache:** support for in-memory cache ([7e7b61b](https://github.com/poppinss/edge/commit/7e7b61b)) | ||
* **component:** add support for define presenter ([7a90885](https://github.com/poppinss/edge/commit/7a90885)) | ||
* **context:** add safe method to ignore escaping ([dfb7d46](https://github.com/poppinss/edge/commit/dfb7d46)) | ||
* **each:** add support for inlcude inside each ([c876c2d](https://github.com/poppinss/edge/commit/c876c2d)) | ||
* **each-tag:** add `isEven` and `isOdd` to ([9be4fbe](https://github.com/poppinss/edge/commit/9be4fbe)) | ||
* **edge:** add support for cache ([3e46c85](https://github.com/poppinss/edge/commit/3e46c85)) | ||
* **expression:** add support for conditional expression ([6b6d1d2](https://github.com/poppinss/edge/commit/6b6d1d2)) | ||
* **globals:** add couple of globals ([f1bf6e0](https://github.com/poppinss/edge/commit/f1bf6e0)) | ||
* **if:** add support for unary expression ([15ea142](https://github.com/poppinss/edge/commit/15ea142)) | ||
* **layout:** add support for [@super](https://github.com/super) keyword ([8f79a9b](https://github.com/poppinss/edge/commit/8f79a9b)) | ||
* **layout:** implement layouts ([56ed7c9](https://github.com/poppinss/edge/commit/56ed7c9)) | ||
* **tag:** add debugger tag ([65ac9cd](https://github.com/poppinss/edge/commit/65ac9cd)) | ||
* **tag:** add raw tag ([9498e63](https://github.com/poppinss/edge/commit/9498e63)) | ||
* **tag:** add unless tag ([5c86bb0](https://github.com/poppinss/edge/commit/5c86bb0)) | ||
* **tags:** implement yield tag ([e1445d8](https://github.com/poppinss/edge/commit/e1445d8)) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
The MIT License (MIT) | ||
Copyright (c) 2016 Harminder Virk | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Edge | ||
> Templating with some fresh air | ||
Edge is a logical templating engine for Node.js. The syntax language is naturally similar to Javascript, making it simpler to write and remember. | ||
|
||
<br /> | ||
|
||
|
||
[![NPM Version][npm-image]][npm-url] | ||
[![Build Status][travis-image]][travis-url] | ||
[![Downloads Stats][npm-downloads]][npm-url] | ||
[![Appveyor][appveyor-image]][appveyor-url] | ||
|
||
<br /> | ||
|
||
--- | ||
|
||
<br /> | ||
|
||
## Features | ||
|
||
1. Beautiful Syntax | ||
2. Encourages component based layout | ||
3. Runtime debugging via chrome devtools. | ||
4. Helpful error messages | ||
5. Support for Layouts | ||
6. Extraction markup via Partials. | ||
|
||
The official documentation will soon be published on http://edge.adonisjs.com | ||
|
||
### Usage | ||
|
||
```js | ||
const edge = require('edge.js') | ||
|
||
// configure cache | ||
edge.configure({ | ||
cache: process.env.NODE_EV === 'production' | ||
}) | ||
|
||
// register views | ||
edge.registerViews(path.join(__dirname, 'views')) | ||
|
||
// render view | ||
edge.render('welcome') | ||
``` | ||
|
||
## Running Tests | ||
|
||
```bash | ||
# just the tests | ||
npm run test:local | ||
|
||
# tests + report coverage on coveralls | ||
npm run test | ||
|
||
# run tests on windows | ||
npm run test:win | ||
|
||
# tests with local coverage report | ||
npm run coverage | ||
``` | ||
|
||
## Running Benchmarks | ||
|
||
Make sure to install `nunjucks` before running benchmarks in comparison to nunjucks. | ||
|
||
``` | ||
node benchmarks/loop.js | ||
node benchmarks/conditionals.js | ||
``` | ||
|
||
[appveyor-image]: https://ci.appveyor.com/api/projects/status/github/poppinss/edge?branch=master&svg=true&passingText=Passing%20On%20Windows | ||
[appveyor-url]: https://ci.appveyor.com/project/thetutlage/edge | ||
|
||
[npm-image]: https://img.shields.io/npm/v/edge.js.svg?style=flat-square | ||
[npm-url]: https://npmjs.org/package/edge.js | ||
|
||
[travis-image]: https://img.shields.io/travis/poppinss/edge/master.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/poppinss/edge | ||
|
||
[npm-downloads]: https://img.shields.io/npm/dm/edge.js.svg?style=flat-square |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
environment: | ||
matrix: | ||
- nodejs_version: 'Stable' | ||
- nodejs_version: '6' | ||
- nodejs_version: '7' | ||
|
||
init: | ||
git config --global core.autocrlf true | ||
|
||
install: | ||
- ps: Install-Product node $env:nodejs_version | ||
- npm install | ||
|
||
test_script: | ||
- node --version | ||
- npm --version | ||
- npm run test:win | ||
|
||
build: off | ||
clone_depth: 1 | ||
|
||
matrix: | ||
fast_finish: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
'use strict' | ||
|
||
const nunjucks = require('nunjucks') | ||
const Benchmark = require('benchmark') | ||
const suite = new Benchmark.Suite() | ||
const edge = new (require('../src/Edge'))() | ||
|
||
const edgeStatement = ` | ||
@if(username === 'virk') | ||
<p> Hello {{ username }} </p> | ||
@else | ||
<p> Hello anonymous </p> | ||
@endif | ||
` | ||
|
||
const nunjucksStatement = ` | ||
{% if username === 'virk' %} | ||
<p> Hello {{ username }} </p> | ||
{% else %} | ||
<p> Hello anonymous </p> | ||
{% endif %} | ||
` | ||
|
||
function compileEdge () { | ||
return edge.compileString(edgeStatement) | ||
} | ||
|
||
nunjucks.configure('', { | ||
noCache: true | ||
}) | ||
|
||
function compileNunjucks () { | ||
return nunjucks.precompileString(nunjucksStatement, { | ||
name: 'foo' | ||
}) | ||
} | ||
|
||
suite.add('Edge', function () { | ||
compileEdge() | ||
}) | ||
.add('Nunjucks', function () { | ||
compileNunjucks() | ||
}) | ||
.on('cycle', function (event) { | ||
console.log(String(event.target)) | ||
}) | ||
.on('complete', function () { | ||
console.log('Fastest is ' + this.filter('fastest').map('name')) | ||
}) | ||
.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
'use strict' | ||
|
||
const nunjucks = require('nunjucks') | ||
const Benchmark = require('benchmark') | ||
const suite = new Benchmark.Suite() | ||
const edge = new (require('../src/Edge'))() | ||
|
||
const edgeStatement = ` | ||
@each(user in users) | ||
{{ user.username }} | ||
@endeach | ||
` | ||
|
||
const nunjucksStatement = ` | ||
{% for user in users %} | ||
{{ user.username }} | ||
{% endfor %} | ||
` | ||
|
||
function compileEdge () { | ||
return edge.compileString(edgeStatement) | ||
} | ||
|
||
const env = new nunjucks.Environment({ | ||
noCache: false | ||
}) | ||
|
||
function compileNunjucks () { | ||
return nunjucks.precompileString(nunjucksStatement, { | ||
name: 'foo', | ||
env: env | ||
}) | ||
} | ||
|
||
suite.add('Edge', function () { | ||
compileEdge() | ||
}) | ||
.add('Nunjucks', function () { | ||
compileNunjucks() | ||
}) | ||
.on('cycle', function (event) { | ||
console.log(String(event.target)) | ||
}) | ||
.on('complete', function () { | ||
console.log('Fastest is ' + this.filter('fastest').map('name')) | ||
}) | ||
.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
'use strict' | ||
|
||
/* | ||
* adonis-edge | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
const shell = require('shelljs') | ||
const ygor = require('ygor') | ||
const semver = require('semver') | ||
const path = require('path') | ||
|
||
const HAS_ASYNC_SUPPORT = semver.satisfies(process.version, '>7.0') | ||
const BIN = HAS_ASYNC_SUPPORT ? 'node --harmony-async-await' : 'node' | ||
const COVERALLS_BIN = './node_modules/.bin/coveralls' | ||
const COVERAGE_DIR = `${path.join(__dirname, '../coverage')}` | ||
const COVERAGE_FILE = `${path.join(COVERAGE_DIR, 'lcov.info')}` | ||
|
||
/** | ||
* Runs test safely without knowing the required | ||
* harmony flags. This command should be consumed | ||
* internally. | ||
*/ | ||
ygor.task('test:safe', () => { | ||
require('require-all')({ | ||
dirname: path.join(__dirname, '../test'), | ||
filter: function (fileName) { | ||
if (!HAS_ASYNC_SUPPORT) { | ||
return !fileName.includes('async.spec.js') && fileName.endsWith('spec.js') | ||
} | ||
return fileName.endsWith('spec.js') | ||
} | ||
}) | ||
}) | ||
|
||
/** | ||
* Runs test suite by adding the harmony async/await | ||
* flag. | ||
*/ | ||
ygor.task('test:local', () => { | ||
if (shell.exec(`FORCE_COLOR=true ${BIN} bin/tasks.js test:safe`).code !== 0) { | ||
shell.echo('test:local command failed') | ||
shell.exit(1) | ||
} | ||
}) | ||
|
||
/** | ||
* Same as test:local, but leaving space if any future | ||
* customizations are required on windows. Also we | ||
* will rely on travis to report coverage report | ||
* to coveralls. | ||
*/ | ||
ygor.task('test:win', () => { | ||
if (shell.exec(`${BIN} bin/tasks.js test:safe`).code !== 0) { | ||
shell.echo('test:win command failed') | ||
shell.exit(1) | ||
} | ||
}) | ||
|
||
/** | ||
* Same as test local, instead it will report the | ||
* coverage info to coveralls. You may need to pass | ||
* SECRETS for coveralls account, but it's better | ||
* to let Travis do that for you. | ||
*/ | ||
ygor.task('test', () => { | ||
const command = `FORCE_COLOR=true ${BIN} ./node_modules/.bin/istanbul cover --hook-run-in-context -x bin/tasks.js bin/tasks.js test:safe && cat ${COVERAGE_FILE} | ${COVERALLS_BIN} && rm -rf ${COVERAGE_DIR}` | ||
|
||
if (shell.exec(command).code !== 0) { | ||
shell.echo('test command failed') | ||
shell.exit(1) | ||
} | ||
}) | ||
|
||
/** | ||
* Runs test and reports coverage to a local | ||
* directory to be viewed by the developer. | ||
*/ | ||
ygor.task('coverage', () => { | ||
const command = `FORCE_COLOR=true ${BIN} ./node_modules/.bin/istanbul cover --hook-run-in-context -x bin/tasks.js bin/tasks.js test:safe` | ||
|
||
if (shell.exec(command).code !== 0) { | ||
shell.echo('coverage command failed') | ||
shell.exit(1) | ||
} | ||
}) |
Oops, something went wrong.