6.1.0 • Published 6 years ago
@rill/html v6.1.0
Universal html rendering middleware for Rill. Uses set-dom to update html in the browser.
Need isomorphic event handling? Check out @rill/delegate!
Installation
npm install @rill/html
Example
// We will use handlebars for our example.
const hbs = require('handlebars')
const homePage = hbs.compile(`
<html>
<head>
<title>My App</title>
<meta name="description" content="Rill Application">
</head>
<body>
{{title}}
<script src="/app.js"/>
</body>
</html>
`)
// Setup a universal Rill application.
const app = require('rill')()
// Setup the html diffing/rendering middleware.
app.use(require('@rill/html')())
// Setup a homepage route.
app.get('/', ({ req, res }, next)=> {
// Just set the response body to some html.
// updates the dom in the browser, or render a string in the server.
res.body = homePage({ title: '@rill/html' });
// On the server the final response will be.
`
<!DOCTYPE html>
<html>
<head>
<title>My App</title>
<meta name="description" content="Rill Application">
</head>
<body>
@rill/html
<script src="/app.js"></script>
</body>
</html>
`
})
Sub page rendering.
Sometimes the goal is not to diff the entire page, or you want to use something like @rill/page to handle the document.
@rill/html adds the ability to change the root element with an option for this purpose.
// Use a query selector to set the root element to diff.
app.use(require('@rill/html')({ root: '#my-element' }))
Contributions
- Use
npm test
to run tests.
Please feel free to create a PR!
6.1.0
6 years ago
6.0.0
7 years ago
5.2.3
7 years ago
5.2.2
7 years ago
5.2.1
7 years ago
5.2.0
7 years ago
5.1.0
7 years ago
5.0.0
8 years ago
4.0.3
8 years ago
4.0.2
8 years ago
4.0.1
8 years ago
4.0.0
8 years ago
3.0.0
8 years ago
2.3.0
8 years ago
2.2.3
8 years ago
2.2.2
8 years ago
2.2.1
8 years ago
2.2.0
8 years ago
2.1.0
8 years ago
2.0.8
8 years ago
2.0.7
8 years ago
2.0.6
8 years ago
2.0.5
8 years ago
2.0.4
8 years ago
2.0.3
8 years ago
2.0.2
8 years ago
2.0.0
8 years ago
1.0.4
8 years ago
1.0.3
8 years ago
1.0.2
8 years ago
1.0.1
8 years ago
1.0.0
8 years ago
0.1.0
8 years ago