# cafescript

> CafeScript is a node component driven preprocessor.

Latest version **0.8.0** (published 2016-08-09) · MIT license · 0 weekly downloads

## Install

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

Provides the command `cafe`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.8.0 |
| Published | 2016-08-09 |
| First published | 2015-10-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Trevor Hall |
| Maintainers | thall |
| Keywords | preprocessor, cafe, cafescript, php |

## Links

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

## Dependencies (2)

- [nopt](https://npm.io/package/nopt.md) ^3.0.4
- [acorn](https://npm.io/package/acorn.md) ^3.3.0

## Recent versions

- 0.8.0 (latest) — 2016-08-09
- 0.7.1 — 2016-08-07
- 0.7.0 — 2016-08-07
- 0.6.1 — 2016-07-01
- 0.6.0 — 2016-07-01
- 0.5.1 — 2016-02-10
- 0.5.0 — 2016-01-28
- 0.4.0 — 2015-12-28
- 0.3.1 — 2015-12-23
- 0.3.0 — 2015-12-22
- 0.2.0 — 2015-12-14
- 0.1.0 — 2015-10-12

## README

# CafeScript
CafeScript is a node component driven preprocessor.

## Usage
CafeScript can be imported as a library that will run .cafe scripts and output them to `process.stdout` or installed globally and run as `$ cafe myfile.cafe`.

### Syntax
CafeScript .cafe files are simillar to .php files.  CafeScript will preprocess the file running the JavaScript code between the `<$ $>` tags.  The JavaScript has access to NodeJS globals as well as a print function.  The print function prints to the output stream which defaults to stdout.

### Standard Out
```
// main.js
require('cafescript');

var script = require('./myscript.cafe');
script();
```

```
<!-- myscript.cafe -->
<$
var hello = 'Hello, World';
$>
<html>
  <head>
    <title><$ print(hello); $></title>
  </head>
  <body>
<$

// Include other scripts like this:
// var script = require('./other.cafe');
// script();

print('CafeScript');

$>
		<div>
<$

// Use inline mode

$>
			<$= 'hello' $>
		</div>
  </body>
</html>
```

### Middleware
CafeScript also exports a middleware function with the signature `function(req, res)` where `res` is an output stream the file will use as an output and `req` is an accesable global `request` in the script.

## Author
Trevor Hall

## License
MIT

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