Socket
Socket
Sign inDemoInstall

edge.js

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

edge.js - npm Package Compare versions

Comparing version 3.2.1 to 3.3.0

build/src/Component/Props.d.ts

17

build/src/Contracts/index.d.ts

@@ -29,2 +29,8 @@ /**

/**
* List of pre-registered template
*/
templates: {
[templatePath: string]: LoaderTemplate;
};
/**
* Save disk name and dirPath to resolve views

@@ -38,3 +44,3 @@ */

/**
* Resolve template contents and optionally the Presenter
* Resolve template contents
*/

@@ -99,3 +105,3 @@ resolve(templatePath: string): LoaderTemplate;

renderInline(templatePath: string, ...localVariables: string[]): Function;
renderWithState(template: string, state: any, slots: any): string;
renderWithState(template: string, state: any, slots: any, caller: any): string;
render(template: string, state: any): string;

@@ -148,2 +154,9 @@ }

};
tags: {
[name: string]: TagContract;
};
/**
* Register a plugin
*/
use(pluginFn: (edge: this) => void): this;
registerTag(tag: TagContract): this;

@@ -150,0 +163,0 @@ registerTemplate(templatePath: string, contents: LoaderTemplate): this;

@@ -8,2 +8,3 @@ import { safeValue } from '../../Context';

} | undefined) => any;
raise: (message: string, options?: any) => never;
excerpt: (value: string, length?: number, options?: {

@@ -10,0 +11,0 @@ strict: boolean;

@@ -16,2 +16,3 @@ "use strict";

const truncatise_1 = __importDefault(require("truncatise"));
const edge_error_1 = require("edge-error");
const inspect_1 = __importDefault(require("@poppinss/inspect"));

@@ -32,2 +33,10 @@ const Context_1 = require("../../Context");

},
raise: (message, options) => {
if (!options) {
throw new Error(message);
}
else {
throw new edge_error_1.EdgeError(message, 'E_RUNTIME_EXCEPTION', options);
}
},
excerpt: (value, length = 20, options) => {

@@ -34,0 +43,0 @@ return truncatise_1.default(value, {

52

build/src/Edge/index.d.ts

@@ -9,2 +9,10 @@ import { Compiler } from '../Compiler';

/**
* Reference to the registered processor handlers
*/
private processor;
/**
* An array of registered plugins
*/
private plugins;
/**
* Globals are shared with all rendered templates

@@ -19,8 +27,6 @@ */

*/
private tags;
tags: {
[name: string]: TagContract;
};
/**
* Reference to the registered processor handlers
*/
private processor;
/**
* The loader to load templates. A loader can read and return

@@ -37,2 +43,12 @@ * templates from anywhere. The default loader reads files

/**
* Execute plugins. Since plugins are meant to be called only
* once we empty out the array after first call
*/
private executePlugins;
/**
* Register a plugin. Plugin functions are called once just before
* an attempt to render a view is made.
*/
use(pluginFn: (edge: this) => void): this;
/**
* Mount named directory to use views. Later you can reference

@@ -103,15 +119,2 @@ * the views from a named disk as follows.

/**
* Render a template with optional state
*
* ```ts
* edge.render('welcome', { greeting: 'Hello world' })
* ```
*/
render(templatePath: string, state?: any): string;
/**
* Returns a new instance of edge. The instance
* can be used to define locals.
*/
getRenderer(): EdgeRendererContract;
/**
* Define processor functions to modify the output of templates

@@ -133,2 +136,15 @@ * at different stages

/**
* Returns a new instance of edge. The instance
* can be used to define locals.
*/
getRenderer(): EdgeRendererContract;
/**
* Render a template with optional state
*
* ```ts
* edge.render('welcome', { greeting: 'Hello world' })
* ```
*/
render(templatePath: string, state?: any): string;
/**
* Share locals with the current view context.

@@ -135,0 +151,0 @@ *

@@ -44,2 +44,10 @@ "use strict";

/**
* Reference to the registered processor handlers
*/
this.processor = new Processor_1.Processor();
/**
* An array of registered plugins
*/
this.plugins = [];
/**
* Globals are shared with all rendered templates

@@ -54,6 +62,2 @@ */

/**
* Reference to the registered processor handlers
*/
this.processor = new Processor_1.Processor();
/**
* The loader to load templates. A loader can read and return

@@ -71,2 +75,21 @@ * templates from anywhere. The default loader reads files

/**
* Execute plugins. Since plugins are meant to be called only
* once we empty out the array after first call
*/
executePlugins() {
if (!this.plugins.length) {
return;
}
this.plugins.forEach((pluginFn) => pluginFn(this));
this.plugins = [];
}
/**
* Register a plugin. Plugin functions are called once just before
* an attempt to render a view is made.
*/
use(pluginFn) {
this.plugins.push(pluginFn);
return this;
}
/**
* Mount named directory to use views. Later you can reference

@@ -158,3 +181,15 @@ * the views from a named disk as follows.

}
process(event, handler) {
this.processor.process(event, handler);
return this;
}
/**
* Returns a new instance of edge. The instance
* can be used to define locals.
*/
getRenderer() {
this.executePlugins();
return new Renderer_1.EdgeRenderer(this.compiler, this.GLOBALS, this.processor);
}
/**
* Render a template with optional state

@@ -170,13 +205,2 @@ *

/**
* Returns a new instance of edge. The instance
* can be used to define locals.
*/
getRenderer() {
return new Renderer_1.EdgeRenderer(this.compiler, this.GLOBALS, this.processor);
}
process(event, handler) {
this.processor.process(event, handler);
return this;
}
/**
* Share locals with the current view context.

@@ -183,0 +207,0 @@ *

@@ -64,2 +64,17 @@ /**

/**
* Returns an object of templates registered as a raw string
*
* ```js
* loader.templates
* // output
*
* {
* 'form.label': { template: '/users/virk/code/app/form/label' }
* }
* ```
*/
get templates(): {
[templatePath: string]: LoaderTemplate;
};
/**
* Mount a directory with a name for resolving views. If name is set

@@ -66,0 +81,0 @@ * to `default`, then you can resolve views without prefixing the

@@ -100,2 +100,20 @@ "use strict";

/**
* Returns an object of templates registered as a raw string
*
* ```js
* loader.templates
* // output
*
* {
* 'form.label': { template: '/users/virk/code/app/form/label' }
* }
* ```
*/
get templates() {
return Array.from(this.preRegistered).reduce((obj, [key, value]) => {
obj[key] = value;
return obj;
}, {});
}
/**
* Mount a directory with a name for resolving views. If name is set

@@ -102,0 +120,0 @@ * to `default`, then you can resolve views without prefixing the

@@ -247,7 +247,11 @@ "use strict";

});
const caller = new StringifiedObject_1.StringifiedObject();
caller.add('filename', '$filename');
caller.add('line', '$lineNumber');
caller.add('col', 0);
/**
* Write the line to render the component with it's own state
*/
buffer.outputExpression(`template.renderWithState(${name}, ${props}, ${obj.flush()})`, token.filename, token.loc.start.line, false);
buffer.outputExpression(`template.renderWithState(${name}, ${props}, ${obj.flush()}, ${caller.flush()})`, token.filename, token.loc.start.line, false);
},
};

@@ -16,1 +16,2 @@ export { ifTag as if } from './If';

export { superTag as super } from './Super';
export { shareTag as share } from './Share';

@@ -11,3 +11,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.super = exports.section = exports.layout = exports.yield = exports.unless = exports.set = exports.debugger = exports.slot = exports.component = exports.each = exports.includeIf = exports.include = exports.elseif = exports.else = exports.if = void 0;
exports.share = exports.super = exports.section = exports.layout = exports.yield = exports.unless = exports.set = exports.debugger = exports.slot = exports.component = exports.each = exports.includeIf = exports.include = exports.elseif = exports.else = exports.if = void 0;
var If_1 = require("./If");

@@ -43,1 +43,3 @@ Object.defineProperty(exports, "if", { enumerable: true, get: function () { return If_1.ifTag; } });

Object.defineProperty(exports, "super", { enumerable: true, get: function () { return Super_1.superTag; } });
var Share_1 = require("./Share");
Object.defineProperty(exports, "share", { enumerable: true, get: function () { return Share_1.shareTag; } });

@@ -47,3 +47,3 @@ import { Processor } from '../Processor';

*/
renderWithState(template: string, state: any, slots: any): string;
renderWithState(template: string, state: any, slots: any, caller: any): string;
/**

@@ -50,0 +50,0 @@ * Render a template with it's state.

@@ -17,2 +17,4 @@ "use strict";

const Context_1 = require("../Context");
const Props_1 = require("../Component/Props");
const Slots_1 = require("../Component/Slots");
/**

@@ -67,5 +69,9 @@ * The template is used to compile and run templates. Also the instance

*/
renderWithState(template, state, slots) {
renderWithState(template, state, slots, caller) {
const { template: compiledTemplate } = this.compiler.compile(template);
const templateState = Object.assign({}, this.sharedState, state, { $slots: slots });
const templateState = Object.assign({}, this.sharedState, state, {
$slots: new Slots_1.Slots({ component: template, caller, slots }),
$caller: caller,
$props: new Props_1.Props({ component: template, state }),
});
const context = new Context_1.Context();

@@ -72,0 +78,0 @@ return this.wrapToFunction(compiledTemplate)(this, templateState, context);

{
"name": "edge.js",
"version": "3.2.1",
"version": "3.3.0",
"description": "Template engine",

@@ -38,5 +38,5 @@ "main": "build/index.js",

"@adonisjs/mrm-preset": "^2.4.0",
"@adonisjs/require-ts": "^1.0.4",
"@adonisjs/require-ts": "^1.1.0",
"@poppinss/dev-utils": "^1.0.11",
"@types/node": "^14.14.6",
"@types/node": "^14.14.7",
"commitizen": "^4.2.2",

@@ -47,3 +47,3 @@ "cz-conventional-changelog": "^3.3.0",

"doctoc": "^1.4.0",
"eslint": "^7.12.1",
"eslint": "^7.13.0",
"eslint-config-prettier": "^6.15.0",

@@ -56,5 +56,5 @@ "eslint-plugin-adonis": "^1.0.15",

"js-stringify": "^1.0.2",
"mrm": "^2.5.8",
"mrm": "^2.5.12",
"np": "^7.0.0",
"npm-audit-html": "^1.4.3",
"npm-audit-html": "^1.5.0",
"prettier": "^2.1.2",

@@ -78,5 +78,6 @@ "typescript": "^4.0.5"

"@poppinss/inspect": "^1.0.1",
"@poppinss/utils": "^2.5.7",
"edge-error": "^1.0.5",
"edge-lexer": "^3.1.6",
"edge-parser": "^5.1.6",
"edge-lexer": "^3.2.0",
"edge-parser": "^5.4.0",
"he": "^1.2.0",

@@ -87,2 +88,3 @@ "lodash.foreach": "^4.5.0",

"macroable": "^5.0.3",
"stringify-attributes": "^2.0.0",
"truncatise": "0.0.8"

@@ -89,0 +91,0 @@ },

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