Render Noddity posts on demand, and cache results in-memory
Last updated 3 years ago by tehshrike .
WTFPL · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install noddity-lazy-static-render 
SYNC missed versions from official npm registry.

A lazy renderer that caches the rendered HTML in-memory so future renders of that page will be as fast as possible.

Whenever a post changes, or the index.json changes, all HTML in the cache is cleared.

Some stuff is still kind of hardcoded - for example, right now it assumes you have a post named post that is your root post. If you need any changes, PRs+tests will be merged happily.


This module exports a single function.

makeLazyRenderer({ butler, data = {}, indexHtml })

Returns a lazyRender function.

  • butler: a noddity-butler instance
  • data [optional]: any data to be merged with the other data passed to Ractive to render the templates
  • indexHtml: a Ractive template for the rendered posts to be embedded in. It has access to the post's metadata object, as well as the html of the rendered file.

lazyRender({ key = '?', file, sessionData = {} })

Returned by the factory function above. Returns a promise that resolves to HTML based on the indexHtml passed to the factory function.

  • file: the post filename to be fetched from the butler.
  • key [optional]: a string identifier used for caching. Should uniquely identify the sessionData.
  • sessionData [optional]: data to be merged with the global data passed to the factory function, plus any data on the post, before rendering the html



markdown: false


title: Sweet example post
date: 2017-01-31T00:32:51.468Z

Some cool post

Library usage:

const lazyRender = createLazyRenderer({
	butler: butler,
	data: {
		siteName: 'Sweet Example Site'
	indexHtml: `<html>

const expected = `<html>
<body><h1>Sweet example post</h1> <article><p>Some cool post</p>

	file: ''
}).then(html => {
	html // => expected



Current Tags

  • 2.0.0                                ...           latest (3 years ago)

5 Versions

  • 2.0.0                                ...           3 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 2
Last Month 1
Dependencies (4)
Dev Dependencies (6)
Dependents (1)

Copyright 2014 - 2016 © |