New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

koa-jade

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-jade - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

28

index.js

@@ -73,4 +73,4 @@ /* jshint noyield: true */

}
, noCache = false
, cachedCompiler = {}
, globalNoCache = false
, compilers = new Map()
, defaultLocals, viewPath

@@ -95,6 +95,5 @@

* @param {Object} options options that pass to Jade compiler, merged with global default options
* @param {Boolean} force true - force to re-compile template instead of use cached compiler
* false - force to use cached compiler
* @param {Boolean} noCache use cache or not
*/
return function* (tpl, locals, options, force) {
return function* (tpl, locals, options, noCache) {
var compileOptions, tplPath, rawJade, compiler, skipCache

@@ -114,13 +113,12 @@

skipCache = options === true || force === true
skipCache = _.isBoolean(options) ? options : _.isBoolean(noCache) ? noCache : globalNoCache
if (!skipCache) {
compiler = cachedCompiler[tplPath]
}
if (skipCache) {
compiler = jade.compile(rawJade, compileOptions)
} else {
compiler = compilers.get(tplPath)
if (!compiler) {
if (noCache === true || skipCache || !cachedCompiler[tplPath]) {
cachedCompiler[tplPath] = compiler = jade.compile(rawJade, compileOptions)
} else {
compiler = cachedCompiler[tplPath]
if (!compiler) {
compiler = jade.compile(rawJade, compileOptions)
compilers.set(tplPath, compiler)
}

@@ -149,3 +147,3 @@ }

if (_.isBoolean(options.noCache)) {
noCache = options.noCache
globalNoCache = options.noCache
}

@@ -152,0 +150,0 @@

{
"name": "koa-jade",
"version": "0.3.0",
"version": "0.3.1",
"description": "A Jade middleware for Koa",

@@ -29,12 +29,12 @@ "main": "index.js",

"dependencies": {
"jade": "~1.7.0",
"fs-extra": "~0.11",
"fs-extra": "^0.12.0",
"jade": "^1.7.0",
"lodash": "*"
},
"devDependencies": {
"gulp": "^3.7",
"gulp-jshint": "^1.6",
"jshint-stylish": "*",
"koa": "^0.6",
"marked": "*"
"gulp": "^3.8.8",
"gulp-jshint": "^1.8.5",
"jshint-stylish": "^1.0.0",
"koa": "^0.12.2",
"marked": "^0.3.2"
},

@@ -41,0 +41,0 @@ "engines": {

@@ -49,3 +49,3 @@ # Koa-jade

`noCache`: if `true`, re-compile templates when page refreshed; if `false`, use cached compiler first. Can be overrided by `render`'s `force`.
`noCache`: use cache or not. Cache could make template rendering 100x faster than without cache. It useful for production, but useless for development (pages would not be updated untill Koa restarted). In most case, `noCache: process.env === 'development'` should be enough. If wanna control it in production for specific page, use `render()`'s `noCache` instead.

@@ -62,3 +62,3 @@ `helperPath`: String or Array, where to load helpers, and make them available on all `.jade`. In Array, you can use object to assgin name for module, eg: `{ random: './path/to/random.js' }`.

### render(tpl, locals, options, force)
### render(tpl, locals, options, noCache)

@@ -69,11 +69,11 @@ Render template, and set rendered template to `this.body`.

`locals`: locals for this page. Optional. If `options` or `force` presented, please use `{}`, `undefined` or `null` for empty `locals`.
`locals`: locals for this page. Optional. If `options` or `noCache` presented, please use `{}`, `undefined` or `null` for empty `locals`.
`options`: override global default options for this page. Only assigning an `object` or a `boolean` to it will take effects.
`force`: tell Jade if force to re-compile template instead loading it from cache. By default, `koa-jade` stores the results of `Jade.compile` in memories, in order to speed up the future request. By setting force to `true` or `false` will force these behaviors: `true` - force to re-compile template instead of use cached compiler, `false` - force to use cached compiler first.
`noCache`: use cache or not. Notes: 1. overrides global `noCache`; 2. won't affect other pages.
If `options` is set to `true` or `false`, will be treated as `force`, and `force` will be ignored. For example, `render(tpl, locals, true)` equals to `render(tpl, locals, {}, true)`, `render(tpl, locals, true, false)` will force re-compilation.
If `options` is set to `true` or `false`, it will be treated as `noCache`, and `noCache` will be ignored. For example, `render(tpl, locals, true)` equals to `render(tpl, locals, {}, true)`, and `render(tpl, locals, true, false)` will skip cache and re-compile template.
`options` and `force` are optional.
`options` and `noCache` are optional.

@@ -80,0 +80,0 @@ ## basedir

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc