# rigidml

> Simplifies website and API development with an easy to use wrapper for HTML, CSS, and a few JS libraries.

Latest version **2.4.1** (published 2020-08-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install rigidml
pnpm add rigidml
yarn add rigidml
bun add rigidml
```

## 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 | 2.4.1 |
| Published | 2020-08-18 |
| First published | 2020-08-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 16.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | rigidity |
| Maintainers | rigidity |
| Keywords | website, template, api, wrapper, html, css, express |

## Links

- npm: https://www.npmjs.com/package/rigidml
- npm.io page: https://npm.io/package/rigidml

## Dependencies (8)

- [jsdom](https://npm.io/package/jsdom.md) ^16.4.0
- [jquery](https://npm.io/package/jquery.md) ^3.5.1
- [express](https://npm.io/package/express.md) ^4.17.1
- [fs-extra](https://npm.io/package/fs-extra.md) ^9.0.1
- [body-parser](https://npm.io/package/body-parser.md) ^1.19.0
- [date-format](https://npm.io/package/date-format.md) ^3.0.0
- [cookie-parser](https://npm.io/package/cookie-parser.md) ^1.4.5
- [express-rate-limit](https://npm.io/package/express-rate-limit.md) ^5.1.3

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 2.4.1 (latest) — 2020-08-18
- 2.4.0 — 2020-08-18
- 2.3.1 — 2020-08-17
- 2.3.0 — 2020-08-17
- 2.2.0 — 2020-08-17
- 2.1.0 — 2020-08-16
- 2.0.1 — 2020-08-16
- 2.0.0 — 2020-08-16
- 1.0.0 — 2020-08-15

## README

# Rigid Markup Library

## Example (index.js)

```js
const {listen} = require("rigidml");

const port = +(process.argv[2] || "8080");
const app = listen(port);
app.pageFile("/", "home.js");
console.log(`The example page is now listening on port ${port}.`);
```

## Example (home.js)

```js
h1 => [
	($id) => 'dissapearing',
	(color) => 'red',
	(fontFamily) => 'Sans-Serif',
	(fontSize) => '64px',
	"Hello, ", p => [
		(color) => 'blue',
		(display) => 'inline-block',
		"world"
	], "!"
],
script => `setTimeout(() => $("#dissapearing").hide(), 5000)`
```

## Scope Object
`this.components` The object that contains all of the components.  
`this.request` The HTTP request object passed from express.  
`this.response` The HTTP response object passed from express.  
`this.path` The directory from which this RML script was called from.  
`this.document` The NodeJS document object which contains the DOM.  
`this.on` Helper that executes an item on a specific element.  
`this.data` Data object that contains items passed from the handler.  

## Application
`app.page(url, text, dir, handler)` Handles get requests with RigidML source text.  
`app.pageFile(url, file, handler)` Handles get requests with a RigidML file.  
`app.api(url, handler)` Handles post requests with an API utility object.  
`app.apiFile(url, file)` Handles post requests in a file in a bound utility object.  
`app.static(path)` Includes a static folder on the application.  
`app.rateLimit(url, amount, seconds, message)` Applies a rate limit to a url.  
`app.get(url, handler)` Handles raw get requests.  
`app.post(url, handler)` Handles raw post requests.  
`app.put(url, handler)` Handles raw put requests.  
`app.patch(url, handler)` Handles raw patch requests.  
`app.delete(url, handler)` Handles raw delete requests.  

## API Utility
`util.request` The raw request object.  
`util.response` The raw response object.  
`util.data` The JSON data parsed from the body.  
`util.cookies` An assignable object of the browser's cookies.  
`util.cookie(key, val, options)` Assigns a cookie to the response.  
`util.result(message)` Sends a 200 status code and an success message.  
`util.error(message)` Sends a 400 status code and an error message.  
`util.updateCookies()` Updates the cookies from the request to the response.  

## Literals
`array` Each item in the list is executed individually.  
`function` Many things can be done with arrow functions, shown below.  
`string` Treated as plain HTML and is appended to the target element.  
`number` Treated as plain HTML and is appended to the target element.  
`boolean` Treated as plain HTML and is appended to the target element.  
`bigint` Treated as plain HTML and is appended to the target element.  
`object` Stringified as JSON and is appended to the target element.  
`symbol` Description treated as plain HTML and is appended to the target element.  
`undefined` Nothing is applied or done with an undefined value.  

## Functions
`key => val` The simplest type of function. Makes an HTML element.  
`(key) => val` Defines a CSS property on the active element.  
`($key) => val` Assigns an HTML property to the active element.  
`($) => val` Includes a file relative to the current file.  
`$key => val` Instantiates an existing component.  
`$ => key => val` Defines a component that can be reused.  
`() => val` Gets executed once the element is reached.

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