Skip to content

Commit

Permalink
Add default map
Browse files Browse the repository at this point in the history
  • Loading branch information
liamqma committed Jul 20, 2016
1 parent 2c41d37 commit 83a1127
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ $ npm install react react-dom jade

## Options

- `map` an object mapping extension names to engine names [`{}`]
- `map` an object mapping extension names to engine names [`{}`]. If not provided, default to [`{ jade: 'jade', js: 'react' }`]
- `default` default extension name to use when missing [`html`]
- `cache` cached compiled functions [NODE_ENV != 'development']

Expand Down Expand Up @@ -80,7 +80,7 @@ console.log(html);

Dependending on your choice of application structure, you may wish to
share these same settings between all of your application, instead of
constantly initializing co-views. To do this simply create a `views.js`
constantly initializing sync-views. To do this simply create a `views.js`
module and export the render function returned:

```js
Expand Down
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { join, extname } from 'path';
import cons from './consolidate';
import { join, extname } from "path";
import cons from "./consolidate";

const env = process.env.NODE_ENV || 'development';

Expand All @@ -9,7 +9,7 @@ export default (dir, opts = {}) => {
const ext = opts.ext || opts.default || 'jade';

// engine map
const map = opts.map || {};
const map = opts.map || { jade: 'jade', js: 'react' };

// cache compiled templates
let cache = opts.cache;
Expand Down
5 changes: 5 additions & 0 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ test('path can contain ext', (t) => {
const render = views(__dirname + '/fixtures', { map: { js: 'react', jade: 'jade' } });
t.is(render('jade/user.jade', locals), html);
t.is(render('react/user.js', locals), html);
});

test('should have default map', (t) => {
const render = views(__dirname + '/fixtures/react', { default: 'js' });
t.is(render('user', locals), html);
});

0 comments on commit 83a1127

Please sign in to comment.