Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove gulp and convert task runner to use NPM scripts #78

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ node_js:
- 7
- 8
- 9
script:
- npm run lint
- npm test
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const app = new koa();

// koa-hbs is middleware. `use` it before you want to render a view
app.use(hbs.middleware({
viewPath: __dirname + '/views'
viewsPath: __dirname + '/views'
}));

// Render is attached to the koa context. Call `this.render` in your middleware
Expand All @@ -51,7 +51,7 @@ variables to be inserted into the template. The result is assigned to Koa's
The plan for koa-hbs is to offer identical functionality as express-hbs
(eventaully). These options are supported _now_.

#### `viewPath` _required_
#### `viewsPath` _required_
Type: `Array|String`
Full path from which to load templates

Expand Down Expand Up @@ -136,7 +136,7 @@ middleware via

```
app.use(hbs.middleware({
viewPath: __dirname + '/views',
viewsPath: __dirname + '/views',
partialsPath: __dirname + '/views/partials'
}));
```
Expand Down Expand Up @@ -164,8 +164,8 @@ the following.

In addition to, or alternatively, you may specify a layout to render a template
into. Simply specify `{{!< layoutName }}` somewhere in your template. koa-hbs
will load your layout from `layoutsPath` if defined, or from `viewPath`
otherwise. If `viewPath` is set to an Array of paths, **_the first path in the
will load your layout from `layoutsPath` if defined, or from `viewsPath`
otherwise. If `viewsPath` is set to an Array of paths, **_the first path in the
array will be assumed to contain the layout named._**

At this time, only a single content block (`{{{body}}}`) is supported.
Expand Down
2 changes: 1 addition & 1 deletion example/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const app = koa();

// koa-hbs is middleware. Use it before you want to render a view
app.use(hbs.middleware({
viewPath: __dirname + '/views'
viewsPath: __dirname + '/views'
}));

// Render is attached to the koa context. Call ctx.render in your middleware
Expand Down
32 changes: 0 additions & 32 deletions gulpfile.js

This file was deleted.

18 changes: 9 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ Hbs.prototype.configure = function (options) {

var self = this;

if (!options.viewPath) {
throw new BadOptionsError('The option `viewPath` must be specified.');
if (!options.viewsPath) {
throw new BadOptionsError('The option `viewsPath` must be specified.');
}

// Attach options
options = options || {};
this.viewPath = options.viewPath;
this.viewsPath = options.viewsPath;
this.handlebars = options.handlebars || this.handlebars;
this.templateOptions = options.templateOptions || {};
this.extname = options.extname || '.hbs';
Expand All @@ -144,8 +144,8 @@ Hbs.prototype.configure = function (options) {
this.disableCache = options.disableCache || false;
this.partialsRegistered = false;

if (!Array.isArray(this.viewPath)) {
this.viewPath = [this.viewPath];
if (!Array.isArray(this.viewsPath)) {
this.viewsPath = [this.viewsPath];
}

// Cache templates and layouts
Expand Down Expand Up @@ -275,7 +275,7 @@ Hbs.prototype.getLayoutPath = function (layout) {
return path.join(this.layoutsPath, layout + this.extname);
}

return path.join(this.viewPath[0], layout + this.extname);
return path.join(this.viewsPath[0], layout + this.extname);
};

/**
Expand Down Expand Up @@ -408,9 +408,9 @@ Hbs.prototype.getTemplatePath = function (tpl) {
if (cache[tpl])
return cache[tpl];

for (i = 0; i !== this.viewPath.length; i++) {
let viewPath = this.viewPath[i],
tplPath = path.join(viewPath, tpl + this.extname);
for (i = 0; i !== this.viewsPath.length; i++) {
let viewsPath = this.viewsPath[i],
tplPath = path.join(viewsPath, tpl + this.extname);

try {
fs.statSync(tplPath);
Expand Down
Loading