Socket
Socket
Sign inDemoInstall

edge.js

Package Overview
Dependencies
Maintainers
2
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 6.0.0-10 to 6.0.0

build/chunk-IEDPZNF7.js

19

build/index.d.ts

@@ -1,15 +0,6 @@

import { E as EdgeGlobals, a as Edge } from './main-2b13330f.js';
export { T as Template } from './main-2b13330f.js';
import 'edge-parser';
import 'edge-lexer/types';
import '@poppinss/macroable';
import 'edge-parser/types';
/**
* Inbuilt globals
*/
declare const edgeGlobals: EdgeGlobals;
import { Edge } from './src/edge/main.js';
export { Template } from './src/template.js';
export { edgeGlobals } from './src/edge/globals.js';
export { Edge };
declare const edge: Edge;
export { Edge, edge as default, edgeGlobals };
export default edge;

@@ -14,3 +14,3 @@ import {

unallowedExpression
} from "./chunk-M6ZFSWKC.js";
} from "./chunk-IEDPZNF7.js";

@@ -54,11 +54,20 @@ // src/loader.ts

const diskBasePath = this.#mountedDirs.get(diskName);
if (!existsSync(join(diskBasePath, componentsDirName))) {
return [];
let files = diskName === "default" ? Array.from(this.#preRegistered.keys()).map((template) => {
return {
fileName: template,
componentPath: template
};
}) : [];
if (existsSync(join(diskBasePath, componentsDirName))) {
files = files.concat(
readdirSync(join(diskBasePath, componentsDirName)).filter((file) => file.endsWith(".edge")).map((template) => {
const fileName = slash(template).replace(/\.edge$/, "");
return {
fileName,
componentPath: `${componentsDirName}/${fileName}`
};
})
);
}
const files = readdirSync(join(diskBasePath, componentsDirName)).filter(
(file) => file.endsWith(".edge")
);
return files.map((file) => {
const fileName = slash(file).replace(/\.edge$/, "");
const componentPath = `${componentsDirName}/${fileName}`;
return files.map(({ fileName, componentPath }) => {
const tagName = fileName.split("/").filter((segment, index) => {

@@ -74,2 +83,16 @@ return index === 0 || segment !== "index";

/**
* Returns a list of templates for a given disk
*/
#getDiskTemplates(diskName) {
const diskBasePath = this.#mountedDirs.get(diskName);
let files = diskName === "default" ? Array.from(this.#preRegistered.keys()) : [];
if (existsSync(diskBasePath)) {
files = files.concat(readdirSync(join(diskBasePath)).filter((file) => file.endsWith(".edge")));
}
return files.map((file) => {
const fileName = slash(file).replace(/\.edge$/, "");
return diskName !== "default" ? `${diskName}::${fileName}` : fileName;
});
}
/**
* Extracts the disk name and the template name from the template

@@ -263,2 +286,15 @@ * path expression.

}
/**
* Returns a list of templates from all the disks and in-memory
* templates as well
*/
listTemplates() {
const diskNames = [...this.#mountedDirs.keys()];
return diskNames.map((diskName) => {
return {
diskName,
templates: this.#getDiskTemplates(diskName)
};
});
}
};

@@ -1511,2 +1547,6 @@

/**
* An array of bundled plugins
*/
#bundledPlugins = [];
/**
* An array of registered plugins

@@ -1541,3 +1581,7 @@ */

});
this.use(pluginSuperCharged, { recurring: !options.cache });
this.#bundledPlugins.push({
fn: pluginSuperCharged,
executed: false,
options: { recurring: !options.cache }
});
}

@@ -1575,6 +1619,18 @@ /**

});
this.#bundledPlugins.filter(({ options, executed }) => {
if (options && options.recurring) {
return true;
}
return !executed;
}).forEach((plugin) => {
plugin.fn(this, !plugin.executed, plugin.options);
plugin.executed = true;
});
}
/**
* Register a plugin. Plugin functions are called once just before
* an attempt to render a view is made.
* Register a plugin. Plugins are called only once just before
* a rendering a view.
*
* You can invoke a plugin multiple times by marking it as a
* recurring plugin
*/

@@ -1764,1 +1820,2 @@ use(pluginFn, options) {

};
//# sourceMappingURL=index.js.map

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

import { P as PluginFn } from '../../main-2b13330f.js';
import 'edge-parser';
import 'edge-lexer/types';
import '@poppinss/macroable';
import 'edge-parser/types';
declare const migrate: PluginFn<undefined>;
export { migrate };
import type { PluginFn } from '../types.js';
export declare const migrate: PluginFn<undefined>;

@@ -8,3 +8,3 @@ import {

unallowedExpression
} from "../../chunk-M6ZFSWKC.js";
} from "../../chunk-IEDPZNF7.js";

@@ -221,1 +221,2 @@ // src/migrate/tags/main.ts

};
//# sourceMappingURL=plugin.js.map

@@ -1,5 +0,132 @@

export * from 'edge-lexer/types';
import 'edge-parser';
export { AcornLoc, ClaimTagFn, MustacheTransformer, OnLineFn, ParserOptions, ParserTagDefinitionContract, TagTransformer } from 'edge-parser/types';
export { f as CacheManagerContract, e as CompiledTemplate, g as CompilerOptions, C as ComponentsTree, k as EdgeBufferContract, E as EdgeGlobals, h as EdgeOptions, b as LoaderContract, L as LoaderTemplate, i as ParserContract, P as PluginFn, c as TagContract, j as TagTokenContract, d as TagsContract } from '../main-2b13330f.js';
import '@poppinss/macroable';
/**
* edge
*
* (c) EdgeJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/// <reference types="node" resolution-mode="require"/>
import type { TagToken } from 'edge-lexer/types';
import type { Parser, EdgeBuffer } from 'edge-parser';
import type { ParserTagDefinitionContract } from 'edge-parser/types';
import type { Edge } from './edge/main.js';
import type { Template } from './template.js';
/**
* The shape in which the loader must resolve the template
*/
export type LoaderTemplate = {
template: string;
};
export type ComponentsTree = {
diskName: string;
components: {
componentName: string;
tagName: string;
}[];
}[];
/**
* Loader contract that every loader must adheres to.
*/
export interface LoaderContract {
/**
* List of mounted disks
*/
mounted: {
[diskName: string]: string;
};
/**
* List of pre-registered template
*/
templates: {
[templatePath: string]: LoaderTemplate;
};
/**
* Save disk name and dirPath to resolve views
*/
mount(diskName: string, dirPath: string | URL): void;
/**
* Remove disk from the previously saved paths
*/
unmount(diskName: string): void;
/**
* Resolve template contents
*/
resolve(templatePath: string): LoaderTemplate;
/**
* Make absolute path to a template
*/
makePath(templatePath: string): string;
/**
* Register in memory template and presenter
*/
register(templatePath: string, contents: LoaderTemplate): void;
/**
* Remove the pre-registered template
*/
remove(templatePath: string): void;
/**
* Returns a list of components for all the registered disks
*/
listComponents(): ComponentsTree;
}
/**
* The tag must have a tagName along with other properties
* required by lexer and parser
*/
export interface TagContract extends ParserTagDefinitionContract {
tagName: string;
boot?(template: typeof Template): void;
}
/**
* Shape of collection of tags
*/
export type TagsContract = {
[tagName: string]: TagContract;
};
/**
* Shape of compiled template as a function
*/
export type CompiledTemplate = (template: Template, state: Record<string, any>, $context: Record<string, any> | undefined, ...localVariables: any[]) => any;
/**
* Shape of the cache manager
*/
export interface CacheManagerContract {
enabled: boolean;
get(templatePath: string): undefined | CompiledTemplate;
set(templatePath: string, compiledOutput: CompiledTemplate): void;
has(templatePath: string): boolean;
delete(templatePath: string): void;
}
/**
* Compiler constructor options
*/
export type CompilerOptions = {
cache?: boolean;
async?: boolean;
compat?: boolean;
};
/**
* Shape of options that can be passed to the
* edge constructor
*/
export type EdgeOptions = {
loader?: LoaderContract;
cache?: boolean;
};
/**
* Shape of edge plugin
*/
export type PluginFn<T> = (edge: Edge, firstRun: boolean, options: T) => void;
/**
* Shape of global helpers
*/
export type EdgeGlobals = Record<string, any>;
/**
* Required when creating custom tags
*/
export type ParserContract = Parser;
export type TagTokenContract = TagToken;
export type EdgeBufferContract = EdgeBuffer;
export type * from 'edge-lexer/types';
export type { AcornLoc, ClaimTagFn, MustacheTransformer, OnLineFn, ParserOptions, ParserTagDefinitionContract, TagTransformer, } from 'edge-parser/types';
{
"name": "edge.js",
"description": "Template engine",
"version": "6.0.0-10",
"version": "6.0.0",
"engines": {

@@ -11,3 +11,7 @@ "node": ">=18.16.0"

"files": [
"build"
"build",
"!build/bin",
"!build/examples",
"!build/tests",
"!build/tests_helpers"
],

@@ -24,3 +28,4 @@ "exports": {

"typecheck": "tsc --noEmit",
"compile": "npm run lint && npm run clean && tsup-node",
"precompile": "npm run lint && npm run clean",
"compile": "tsup-node && tsc --emitDeclarationOnly --declaration",
"build": "npm run compile",

@@ -39,36 +44,36 @@ "prepublishOnly": "npm run build",

"@adonisjs/tsconfig": "^1.1.8",
"@commitlint/cli": "^17.6.7",
"@commitlint/config-conventional": "^17.6.7",
"@japa/assert": "2.0.0-1",
"@japa/file-system": "2.0.0-1",
"@japa/runner": "3.0.0-6",
"@commitlint/cli": "^18.2.0",
"@commitlint/config-conventional": "^18.1.0",
"@japa/assert": "^2.0.1",
"@japa/file-system": "^2.0.1",
"@japa/runner": "^3.0.5",
"@poppinss/dev-utils": "^2.0.3",
"@swc/core": "^1.3.70",
"@types/fs-readdir-recursive": "^1.1.0",
"@types/he": "^1.2.0",
"@types/node": "^20.4.4",
"@swc/core": "^1.3.96",
"@types/fs-readdir-recursive": "^1.1.1",
"@types/he": "^1.2.2",
"@types/node": "^20.8.10",
"c8": "^8.0.0",
"dedent-js": "^1.0.1",
"del-cli": "^5.0.0",
"eslint": "^8.45.0",
"del-cli": "^5.1.0",
"eslint": "^8.53.0",
"github-label-sync": "^2.2.0",
"husky": "^8.0.3",
"np": "^8.0.4",
"prettier": "^3.0.0",
"prettier": "^3.0.3",
"ts-node": "^10.9.1",
"tsup": "^7.1.0",
"typescript": "^5.1.6"
"typescript": "^5.2.2"
},
"dependencies": {
"@poppinss/inspect": "^1.0.1",
"@poppinss/macroable": "^1.0.0-7",
"@poppinss/utils": "^6.5.0-5",
"@poppinss/macroable": "^1.0.0",
"@poppinss/utils": "^6.5.1",
"classnames": "^2.3.2",
"edge-error": "^4.0.0-0",
"edge-lexer": "^6.0.0-4",
"edge-parser": "^9.0.0-3",
"edge-error": "^4.0.0",
"edge-lexer": "^6.0.0",
"edge-parser": "^9.0.0",
"fs-readdir-recursive": "^1.1.0",
"he": "^1.2.0",
"js-stringify": "^1.0.2",
"property-information": "^6.2.0",
"property-information": "^6.4.0",
"stringify-attributes": "^4.0.0"

@@ -106,7 +111,7 @@ },

"access": "public",
"tag": "next"
"tag": "latest"
},
"np": {
"message": "chore(release): %s",
"tag": "next",
"tag": "latest",
"branch": "main",

@@ -133,5 +138,6 @@ "anyBranch": false

"format": "esm",
"dts": true,
"dts": false,
"sourcemap": true,
"target": "esnext"
}
}

@@ -1,63 +0,9 @@

<div align="center"><img src="https://res.cloudinary.com/adonis-js/image/upload/v1620150474/edge-banner_tzmnox.jpg" width="600px"></div>
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
## Table of contents
- [Table of contents](#table-of-contents)
- [Maintainers](#maintainers)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
# Edge
> A template for Node.js
[![gh-workflow-image]][gh-workflow-url] [![typescript-image]][typescript-url] [![npm-image]][npm-url] [![license-image]][license-url] [![synk-image]][synk-url]
[![gh-workflow-image]][gh-workflow-url] [![typescript-image]][typescript-url] [![npm-image]][npm-url] [![license-image]][license-url]
Edge is a logical and batteries included template engine for Node.js. It can render any text based format, whether is **HTML**, **Markdown** or **plain text** files.
Edge is a simple, Modern, and batteries included template engine for Node.js. Edge is similar to writing JavaScript. If you know JavaScript, you know Edge.
## Usage
Install the package from the npm registry.
## 👉 [Learn more](https://edgejs.dev)
```sh
npm i edge.js
# yarn
yarn add edge.js
```
And use it as follows
```js
const { join } = require('path')
// CommonJS
const { Edge } = require('edge.js')
// Typescript import
// import { Edge } from 'edge.js'
const edge = new Edge({ cache: false })
edge.mount(join(__dirname, 'views'))
const html = await edge.render('welcome', {
greeting: 'Hello world'
})
console.log(html)
```
Next create the `views/welcome.edge` file.
```edge
<p> {{ greeting }} </p>
```
Edge was created to be used inside the AdonisJS framework. However it is a framework agnostic library and can be used standalone as well.
The documentation is written on the [AdonisJS website](https://docs.adonisjs.com/guides/views/rendering). In AdonisJS docs, we refer the `edge` variable as `view`.
<br />
<hr>
![](https://cdn.jsdelivr.net/gh/thetutlage/static/sponsorkit/sponsors.png)

@@ -76,4 +22,1 @@

[npm-url]: https://npmjs.org/package/edge.js 'npm'
[synk-image]: https://img.shields.io/snyk/vulnerabilities/github/edge-js/edge?label=Synk%20Vulnerabilities&style=for-the-badge
[synk-url]: https://snyk.io/test/github/edge-js/edge?targetFile=package.json "synk"
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