Skip to content

Commit

Permalink
docs: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Mar 22, 2017
1 parent 7a90885 commit a84148e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 41 deletions.
46 changes: 6 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,67 +1,33 @@
# Edge

## Exception Handling

In order to make sure that edge serves it purpose, we need solid exception handling inside the entire code base.

## First Level Benchmarks

### Simple Conditionals (compile only)
```
Edge x 68,128 ops/sec ±2.66% (86 runs sampled)
Nunjucks x 5,766 ops/sec ±3.19% (83 runs sampled)
Edge x 44,159 ops/sec ±1.02% (86 runs sampled)
Nunjucks x 5,227 ops/sec ±2.51% (80 runs sampled)
Fastest is Edge
```

### Each Loop (compile only)
```
Edge x 72,273 ops/sec ±0.79% (91 runs sampled)
Nunjucks x 5,823 ops/sec ±2.69% (83 runs sampled)
Edge x 35,930 ops/sec ±2.07% (81 runs sampled)
Nunjucks x 5,161 ops/sec ±2.12% (80 runs sampled)
Fastest is Edge
```


### Lexer Exceptions

Lexer exceptions should be broad and does not contain any domain logic, since Lexer has no idea about the template context and basically is a simple Javascript expression parser.

1. Make sure to pass `indexno` whenever possible.
2. Make sure to mention `Report package author.` When something unexpected happens.

### Template Compiler

Template compiler should throw domain specific exceptions. It should have `lineno:`, `indexno:` with each exception.

Also it should format exceptions by mentioning the tag on which it happend and the **untouched statement** which was responsible for it.

Also tags can catch exceptions by themselves, but if they don't the template compiler is responsible for generating best possible exceptions

### Template Runner

At this point we should be 90% cover, since Javascript keeps lot of runtime context, there are chances that templates may break in runtime.

> NEED MORE THINKING HERE.

### Usage

```
const edge = require('edge')
edge.compiledDir('out') // optional
edge.registerViews(path.join(__dirname, 'views')) // mount views
edge.registerPresenters(path.join(__dirname, 'views')) // mount presenters
edge.render('somepath') // mounting required
edge.renderString() // a plain string
edge.compile() // compile a file - mounting required
edge.compileString() // compile a string to a function
edge.render('welcome')
edge.tag() // register a tag
edge.global() // register a global
edge.presenter().render() // render with presenter
edge.doNotCompile() // do not compile in runtime
edge.share().render() // share locals and render
```
2 changes: 1 addition & 1 deletion benchmarks/conditional.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const nunjucksStatement = `
`

function compileEdge () {
return edge.compileString(edgeStatement, { username: 'virk' })
return edge.compileString(edgeStatement)
}

nunjucks.configure('', {
Expand Down

0 comments on commit a84148e

Please sign in to comment.