# inflict

> A flexible web framework

Latest version **4.0.0** (published 2023-03-18) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2023-03-18 |
| First published | 2023-02-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 15.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | intfract |
| Maintainers | fract |
| Keywords | framework |

## Links

- npm: https://www.npmjs.com/package/inflict
- Repository: https://github.com/InflictJS/inflict
- Homepage: https://github.com/InflictJS/inflict#readme
- Issues: https://github.com/InflictJS/inflict/issues
- npm.io page: https://npm.io/package/inflict

## Dependencies (4)

- [fs](https://npm.io/package/fs.md) ^0.0.1-security
- [tsc](https://npm.io/package/tsc.md) ^2.0.4
- [express](https://npm.io/package/express.md) ^4.18.2
- [typescript](https://npm.io/package/typescript.md) ^4.9.5

## Alternatives

- [@sveltejs/kit](https://npm.io/package/@sveltejs/kit.md) — 2.2M weekly downloads
- [@atlaskit/theme](https://npm.io/package/@atlaskit/theme.md) — 402.0K weekly downloads
- [@tangle-network/brand](https://npm.io/package/@tangle-network/brand.md) — 10.0K weekly downloads
- [seneca](https://npm.io/package/seneca.md) — 7.4K weekly downloads
- [@bsb/base](https://npm.io/package/@bsb/base.md) — 7.2K weekly downloads

## Recent versions

- 4.0.0 (latest) — 2023-03-18
- 3.1.0 — 2023-02-15
- 3.0.0 — 2023-02-15
- 2.0.0 — 2023-02-10
- 1.3.0 — 2023-02-08
- 1.2.0 — 2023-02-08
- 1.1.0 — 2023-02-06
- 1.0.0 — 2023-02-06

## README

# Inflict

A flexible HTML web framework!

## Import

Install `inflict` with [npm](https://npmjs.com/package/inflict).

```sh
npm install inflict
```

> **Note**
> This package uses ESM by default but supports CJS 

### ESM 

```js
import { render } from 'inflict'
```

### CJS

```js
const { render } = require('inflict')
```

## Get Started

Create an express server and render an `html` template that is **not** in the `express.static()` folder. 

```js
import { render } from 'inflict'
import express from 'express'
const app = express()

app.use(express.static('public'))

app.get('/', async (req, res) => {
  res.send(render('views', '', { message: 'Hello!', todo: ['Eat', 'Code'] })) // views/index.html is rendered
})

app.listen(3000)
```

Templates are placed inside `#{}#` hash brackets that return strings as plain text. 
> **Warning**
> Do not use `//` to comment or line breaks because code is evaluated in a single line

```html
<!DOCTYPE html>
<html lang="en">
<head>
  #{ include('meta.html') }#
  <title>Inflict</title>
  #{ include('cdn.html') }#
</head>
<body>
  <main>
    #{ message }#
    <ul>
      #{ loop(todo, (item, i) => element('li', item, { class: 'item' })) }#
    </ul>
  </main>
</body>
</html>
```

## File Inclusion Syntax

Relative paths are used by default. Absolute paths using `$` refer to the first folder `views` unless specified when using the `render()` function. This feature is useful because `render()` carries over the `dir` parameter when using `include()` in templates. 

```html
<!-- views/page/index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Inflict</title>
</head>
<body>
  <!-- views/widget.html -->
  #{ include('$widget.html') }#
  <!-- coming soon... -->
  <script src="$script.js"></script>
</body>
</html>
```

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