# data-render

> A Express.js middleware that pass data to render templates automatically

Latest version **1.0.1** (published 2016-01-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install data-render
pnpm add data-render
yarn add data-render
bun add data-render
```

## 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.1 |
| Published | 2016-01-18 |
| First published | 2016-01-07 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Gabriel Alves |
| Maintainers | itsmealves |
| Keywords | data, render, pass, template, express |

## Links

- npm: https://www.npmjs.com/package/data-render
- Repository: https://github.com/ItsMeAlves/data-render
- Homepage: https://github.com/itsmealves/data-render#readme
- Issues: https://github.com/itsmealves/data-render/issues
- npm.io page: https://npm.io/package/data-render

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2016-01-18
- 1.0.0 — 2016-01-07

## README

# data-render
A Express.js middleware that pass data to templates automatically through render.

# Install it
<code>npm install data-render --save</code>

# Use it
You can do this in two ways. The first one is:

	var express = require('express');
	var dataRender = require('data-render');
	var app = express();
	
	//Use it as a middleware and pass your data as a object
	//Pass as the object key the property you want to call inside the template
	app.use(dataRender({
		pageContent: 'Some text here',  //Its value has to be a string
		userAuthenticated: {            //But if you wish to eval this string, make another object with content and eval keys
	    	content:'request.user',       //The content key stores your data
	    	eval: true                    //eval key verifies if data has to be evaluated
		}
	}));

Or, you can pass it in routing:


	var data = {
		pageContent: 'Some text here,
	  	userAuthenticated: {
	 		content:'request.user',
	    	eval: true
		}
	};
	
	app.get('/your/route', dataRender(data), function(req, res) {
	 	res.render('your/template);
	});


A sample ejs template could be one like this:



	<h1>Welcome</h1>
	<p><%= pageContent %></p> <!-- uses the key name -->
	<p>Username: <%= userAuthenticated.username %>


&copy; Gabriel Alves (ItsMeAlves)

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