Skip to content
Converts pug templates to an image
JavaScript HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
LICENSE
README.md
index.js
package-lock.json
package.json
test.js
test.pug

README.md

Pug To Image

Takes a Pug template file and associated options as inputs and outputs an image.

Installation

npm install pug-to-image

Example

const pugToImage = require("pug-to-image");
const fs = require("fs");

const imageType = "PNG"; // Any PhantomJS image type
const width = 512;
const height = 512;
const filename = "filename.pug";
const destination = "image.png";
const options = { name: "Jordan" }; // Just example variables which are going to be passed off to pug to be rendered

pugToImage(imageType, width, height, filename, options).then((buffer) => {
    // Write the buffer to a file
    fs.writeFile("image.png", buffer, () => console.log("Saved :)"));

    // Or maybe tweet the image, using an example function `tweetImage`
    tweetImage(buffer, () => console.log("Tweeted :)"));
});
  • pugToImage is also curried

Author

Jordan Lord

License

Apache License 2.0

You can’t perform that action at this time.