Skip to content
This repository has been archived by the owner on Dec 25, 2023. It is now read-only.

staticpagesjs/twig-writer

Repository files navigation

Static Pages / Twig File Writer

Renders page data via twig templates into files.

Merges the @static-pages/file-writer and @static-pages/twig-renderer packages together for convenience.

This package is part of the StaticPagesJs project, see:

Usage

import twigWriter from '@static-pages/twig-writer';

const writer = twigWriter({
	outDir: 'dist',
	outFile: d => d.urlPrefix + d.url,
	viewsDir: 'myViews',
	view: 'content.twig',
});

const pageData = { title: 'Page header', body: 'My Content' };

writer({ value: pageData }); // writes the rendered page to the disk as a file.

Options

The available options are an union of the file-writer options and the twig-renderer options.