Skip to content

mjm/nunjucks-s3-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nunjucks-s3-loader

A Loader for nunjucks that downloads templates from an S3 bucket.

This loader is intended for server-side rendering, where nunjucks can cache the compiled template.

Note: Using this loader requires you to use the asynchronous version of nunjucks's render method.

Install

npm i nunjucks-s3-loader

Example

import * as nunjucks from "nunjucks";
import S3Loader from "nunjucks-s3-loader";

const loader = new S3Loader({
  bucket: 'your-bucket-name', // Required
  prefix: '_templates/',      // Optional
});
const env = new nunjucks.Environment(loader);

env.render('post.html', { title: 'My Blog Post' }, (err, res) => {
  // ...
});

If you need to, you can pass in a custom S3 client:

const s3 = new S3({ ... });
const loader = new S3Loader({
  bucket: 'your-bucket-name',
  client: s3
});

About

Load nunjucks templates from Amazon S3

Resources

Stars

Watchers

Forks

Packages

No packages published