+6
-0
@@ -7,2 +7,3 @@ | ||
| var debug = require('debug')('co-views'); | ||
| var merge = require('utils-merge'); | ||
| var render = require('co-render'); | ||
@@ -54,2 +55,7 @@ var path = require('path'); | ||
| // merge opts.locals | ||
| if (opts.locals) { | ||
| merge(locals, opts.locals); | ||
| } | ||
| // default extname | ||
@@ -56,0 +62,0 @@ var e = extname(view); |
+12
-9
| { | ||
| "name": "co-views", | ||
| "version": "0.2.0", | ||
| "version": "0.3.0", | ||
| "repository": "visionmedia/co-views", | ||
@@ -13,15 +13,18 @@ "description": "Higher level thunk-based template rendering for Co and others, built on co-render", | ||
| ], | ||
| "files": [ | ||
| "index.js" | ||
| ], | ||
| "dependencies": { | ||
| "debug": "*", | ||
| "co-render": "0.0.1" | ||
| "co-render": "0", | ||
| "debug": "2", | ||
| "utils-merge": "1" | ||
| }, | ||
| "devDependencies": { | ||
| "mocha": "*", | ||
| "should": "*", | ||
| "co": "~1.5.2", | ||
| "ejs": "~0.8.4", | ||
| "swig": "~1.0.0-rc1", | ||
| "jade": "~0.35.0" | ||
| "co": "4", | ||
| "ejs": "2", | ||
| "jade": "1", | ||
| "mocha": "2", | ||
| "swig": "1" | ||
| }, | ||
| "license": "MIT" | ||
| } |
+9
-9
| # co-views | ||
| Template rendering for [co](https://github.com/visionmedia/co) using | ||
| [co-render](https://github.com/visionmedia/co-render). This module | ||
| Template rendering for [co](https://github.com/tj/co) using | ||
| [co-render](https://github.com/tj/co-render). This module | ||
| provides higher level sugar than co-render to reduce redundancy, | ||
@@ -22,4 +22,4 @@ for example specifying a views directory and default extension name. | ||
| - `map` an object mapping extnames to engine names [`{}`] | ||
| - `ext` default esxtname to use when missing [`html`] | ||
| - `map` an object mapping extension names to engine names [`{}`] | ||
| - `default` default extension name to use when missing [`html`] | ||
| - `cache` cached compiled functions [NODE_ENV != 'development'] | ||
@@ -36,5 +36,5 @@ | ||
| ### ext | ||
| ### default | ||
| Set the default template extension when none is passed to | ||
| Set the default template extension when none is passed to | ||
| the render function. This defaults to "html". For example | ||
@@ -45,6 +45,6 @@ if you mostly use Jade, then you'd likely want to assign | ||
| ```js | ||
| { ext: 'jade' } | ||
| { default: 'jade' } | ||
| ``` | ||
| Allowing you to invoke `render('user')` instead of | ||
| Allowing you to invoke `render('user')` instead of | ||
| `render('user.jade')`. | ||
@@ -96,3 +96,3 @@ | ||
| console.log(html); | ||
| })(); | ||
| }); | ||
| ``` | ||
@@ -99,0 +99,0 @@ |
Sorry, the diff of this file is not supported yet
| <html> | ||
| <head> | ||
| <title>MyApp - <%= title %></title> | ||
| </head> | ||
| <body> | ||
| <h1><%= title %></h1> | ||
| <%- body %> | ||
| </body> | ||
| </html> |
| /** | ||
| * Module dependencies. | ||
| */ | ||
| var co = require('co'); | ||
| var views = require('..'); | ||
| var render = views('examples', { | ||
| ext: 'ejs' | ||
| }); | ||
| var tobi = { | ||
| name: 'tobi', | ||
| species: 'ferret' | ||
| }; | ||
| var loki = { | ||
| name: 'loki', | ||
| species: 'ferret' | ||
| }; | ||
| var luna = { | ||
| name: 'luna', | ||
| species: 'cat' | ||
| }; | ||
| var db = { | ||
| users: [tobi, loki, luna] | ||
| }; | ||
| co(function *(){ | ||
| var users = yield renderEach('user', db.users); | ||
| var html = yield render('layout', { title: 'Users', body: users }); | ||
| console.log(html); | ||
| }); | ||
| /** | ||
| * Render each `objs` with template `name`. | ||
| * | ||
| * This function executes render() calls in parallel, | ||
| * but retains order, since co's array support | ||
| * assigns results properly for us: | ||
| * | ||
| * https://github.com/visionmedia/co/blob/master/index.js#L148 | ||
| * | ||
| * This is effectively equivalent to: | ||
| * | ||
| * var a = render('user', { user: tobi }); | ||
| * var b = render('user', { user: loki }); | ||
| * var c = render('user', { user: jane }); | ||
| * return a + b + c; | ||
| * | ||
| * @param {String} name | ||
| * @param {Array} objs | ||
| * @return {String} | ||
| * @api public | ||
| */ | ||
| function *renderEach(name, objs) { | ||
| var res = yield objs.map(function(obj){ | ||
| var opts = {}; | ||
| opts[name] = obj; | ||
| return render(name, opts); | ||
| }); | ||
| return res.join('\n'); | ||
| } |
| <p><%= user.name %> is a <%= user.species %><p> |
| <p>{{user.name}} is a {{user.species}}<p> |
| p #{user.name} is a #{user.species} |
| /** | ||
| * Module dependencies. | ||
| */ | ||
| var co = require('co'); | ||
| var views = require('..'); | ||
| var render = views('examples', { | ||
| map: { html: 'swig' } | ||
| }); | ||
| var tobi = { | ||
| name: 'tobi', | ||
| species: 'ferret' | ||
| }; | ||
| var loki = { | ||
| name: 'loki', | ||
| species: 'ferret' | ||
| }; | ||
| var luna = { | ||
| name: 'luna', | ||
| species: 'cat' | ||
| }; | ||
| co(function *(){ | ||
| var a = render('user', { user: tobi }); | ||
| var b = render('user.jade', { user: loki }); | ||
| var c = render('user.ejs', { user: luna }); | ||
| var html = yield [a, b, c]; | ||
| html = html.join(''); | ||
| console.log(html); | ||
| })(); |
-7
| test: | ||
| @./node_modules/.bin/mocha \ | ||
| --reporter dot \ | ||
| --bail | ||
| .PHONY: test |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
5
-16.67%1
-50%2
-33.33%4775
-29.26%3
50%4
-66.67%62
-56.03%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
Updated
Updated