Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/reggi/jrender

A super renderer for express, that allows you to edit views in jQuery.
https://github.com/reggi/jrender

Last synced: about 1 month ago
JSON representation

A super renderer for express, that allows you to edit views in jQuery.

Awesome Lists containing this project

README

        

# jRender

Edit your views with a jQuery server-side postprocessor.

## Installation

```
npm install jrender --save
```

## Setup

Here's the middleware in app.js.

```
var jrender = require("jrender");
app.use(jrender());
```

## Usage

Here's a route.

```
var route = function(req, res, next){
res.jrender('index', { title: 'Express' }, function($){
$("title").attr("jquery","awesome");
});
};
```

If you need the string, and don't wanna send you can pass in the last callback.

```
var route = function(req, res, next){
res.jrender('index', { title: 'Express' }, function($){
$("title").attr("jquery","awesome");
}, function(err, html){
if(err) return next(err);
return res.send(html);
});
};
```