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

vision

Package Overview
Dependencies
Maintainers
6
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vision - npm Package Compare versions

Comparing version 5.3.0 to 5.3.1

examples/marko/templates/components/app-component/index.marko

12

API.md

@@ -1,2 +0,2 @@

# API Reference
# v5.3.x API Reference

@@ -7,3 +7,3 @@ Most interaction with **vision** is done via the `h` [response toolkit](https://github.com/hapijs/hapi/blob/master/API.md#response-toolkit)

- [Registration](#registration)
- [View Manager](#view-manager)
- [Views Manager](#views-manager)
- [`options`](#options)

@@ -23,3 +23,3 @@ - [`manager.registerHelper(name, helper)`](#managerregisterhelpername-helper)

Vision can be registered multiple times and receives [`view manager options`](#options) as registration options.
Vision can be registered multiple times and receives [`views manager options`](#options) as registration options.

@@ -49,5 +49,5 @@ Example:

## View Manager
## Views Manager
The View Manager is configured with [`registration options`](#registration) or by calling [`server.views(options)`](#serverviewsoptions)
The Views Manager is configured with [`registration options`](#registration) or by calling [`server.views(options)`](#serverviewsoptions)

@@ -148,3 +148,3 @@ ## `options`

- Initializes a plugin's view manager by receiving [`manager options`](#options)
- Returns the newly created [view manager](#view-manager) for the plugin that called it.
- Returns the newly created [view manager](#views-manager) for the plugin that called it.

@@ -151,0 +151,0 @@ ### `server.render(template, context, [options], [callback])`

@@ -6,5 +6,6 @@ 'use strict';

const Vision = require('../..');
const Marko = require('marko');
const Path = require('path');
const Marko = require('marko');
require('marko/node-require');

@@ -34,3 +35,5 @@ // Declare internals

const server = Hapi.Server({ port: 3000 });
const server = Hapi.server({
port: 3000
});

@@ -40,2 +43,3 @@ await server.register(Vision);

server.views({
relativeTo: __dirname,
engines: {

@@ -45,3 +49,6 @@ marko: {

const opts = { preserveWhitespace: true, writeToDisk: false };
const opts = {
preserveWhitespace: true,
writeToDisk: false
};

@@ -57,7 +64,10 @@ const template = Marko.load(options.filename, opts);

},
relativeTo: __dirname,
path: `templates/${internals.templatePath}`
});
server.route({ method: 'GET', path: '/', handler: rootHandler });
server.route({
method: 'GET',
path: '/',
handler: rootHandler
});

@@ -64,0 +74,0 @@ await server.start();

@@ -81,4 +81,9 @@ 'use strict';

const manager = internals.nearestManager(realm);
Hoek.assert(manager, 'Missing views manager');
Hoek.assert(manager, 'Missing views manager');
if (!isServer) {
// this is the request
return await manager.render(template, context, options, this);
}
return await manager.render(template, context, options);

@@ -85,0 +90,0 @@ };

@@ -11,7 +11,5 @@ 'use strict';

const Items = require('items');
// Additional helper modules required in constructor
// Declare internals
const internals = {};

@@ -290,21 +288,20 @@

internals.Manager.prototype.render = function (filename, context, options, callback) {
internals.Manager.prototype.render = function (filename, context, options, request) {
if (!callback) {
return internals._wrapMethod(this, this.render, [filename, context, options]);
}
return new Promise((resolve, reject) => {
this._prepare(filename, options, (err, compiled) => {
this._prepare(filename, options, (err, compiled) => {
if (err) {
return callback(err);
}
this._render(compiled, context, null, (err, rendered) => {
if (err) {
return callback(err);
return reject(err);
}
return callback(null, rendered, compiled.settings);
this._render(compiled, context, request, (err, rendered) => {
if (err) {
return reject(err);
}
return resolve(rendered);
});
});

@@ -629,19 +626,1 @@ });

};
internals._wrapMethod = (bind, method, args) => {
return new Promise((resolve, reject) => {
const callback = function (err, result) {
if (err) {
return reject(err);
}
return resolve(result);
};
method.apply(bind, args.concat(callback));
});
};
{
"name": "vision",
"description": "Templates rendering plugin support for hapi.js",
"version": "5.3.0",
"version": "5.3.1",
"repository": "git://github.com/hapijs/vision",

@@ -6,0 +6,0 @@ "main": "lib/index.js",

@@ -395,3 +395,3 @@ 'use strict';

it('does not pass the request to the global context function (request)', async () => {
it('passes the request to the global context function (request)', async () => {

@@ -414,3 +414,3 @@ const server = Hapi.server();

const res = await server.inject({ method: 'GET', url: '/' });
expect(res.result).to.contain('<h1>default</h1>');
expect(res.result).to.contain('<h1>/</h1>');
});

@@ -417,0 +417,0 @@

Sorry, the diff of this file is not supported yet

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