# @diegab/epsilon

> A work-in-progress web framework that lets you run code before HTML is rendered.

Latest version **1.0.3** (published 2022-09-04) · ISC license · 0 weekly downloads

## Install

```sh
npm install @diegab/epsilon
pnpm add @diegab/epsilon
yarn add @diegab/epsilon
bun add @diegab/epsilon
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2022-09-04 |
| First published | 2022-09-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | diegab |

## Links

- npm: https://www.npmjs.com/package/@diegab/epsilon
- npm.io page: https://npm.io/package/@diegab/epsilon

## Dependencies (1)

- [node-html-parser](https://npm.io/package/node-html-parser.md) ^5.4.2

## Recent versions

- 1.0.3 (latest) — 2022-09-04
- 1.0.1 — 2022-09-04
- 1.0.0 — 2022-09-04

## README

# Epsilon
A work-in-progress web framework that lets you run code before HTML is rendered.

# Usage
index.js:
```js
const express = require('express');
const epsilon = require('@diegab/epsilon');
const app = express();

epsilon.attach(app);
epsilon.render('public/main.epsln', '/');

app.listen(8080);
```
public/main.epsln:
```html
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
    <h1> Hello, World! </h1>
    <p> The date is: %{new Date()}, and this platform is %{process.platform}. </p>
    <p> Here's some color:
    <p id="color"></p>
    </p>
    <script epsilon>
        var colors = require('@colors/colors');
        var Convert = require('ansi-to-html');
        var convert = new Convert();

        document.querySelector('#color').innerHTML = convert.toHtml("CoLoRs!!".rainbow);
    </script>
    <script>
        alert('Some script that runs in the browser, not in the server.');
    </script>
</html>
```
Results in:

![Epsilion Result](https://gitlab.com/Unzor/epsilon/-/raw/main/screenshots/1.png)

# Documentation
- `epsilon.attach`:
    - Attaches Epsilon to an Express router.
    - Usage: 
    ```js
    const express = require("express");
    const epsilon = require("@diegab/epsilon");
    const app = express();
    epsilion.attach(app);
    ```
- `epsilon.render`:
    - Renders an Epsilion template to a path.
    - Usage: `epsilion.render("path/to/page.epsln", "/")`
- `epsilon.text_render`:
    - Renders an Epsilion template (in form of a string) to a path.
    - Usage: `epsilion.text_render("<h1> The date is: %{new Date()} </h1>", "/")`
- `epsilon.render_with_changes`:
    - Renders an Epsilion template to a path, but instead of having to render once, it will render the page every time it is loaded. 
    - Usage: `epsilion.text_render_with_changes("path/to/page.epsln", "/")`
- `epsilon.render_text_with_changes`:
    - Renders an Epsilion template (in form of a string) to a path, but instead of having to render once, it will render the page every time it is loaded. Not recommended as loading times will be slower.
    - Usage: `epsilion.render_text_with_changes("<h1> The date is: %{new Date()} </h1>", "/")`
- `epsilon.toHTML`:
    - Converts an Epsilion template (in form of a string) to HTML, but instead of having to render once, it will render the page every time it is loaded.  Not recommended as loading times will be slower.
    - Usage: `epsilion.toHTML("<h1> The date is: %{new Date()} </h1>")`

---
_Source: https://npm.io/package/@diegab/epsilon · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
