gulp plugin to build templates, using tateru-cli
Simple gulp plugin for streamlining integration of the tateru-cli into gulp workflow. If you encounter problems related to file generation, please report them in the tateru-cli issues. Only create a new issue if it looks like you're having a problem with the plugin itself.
- Node.js v14 or higher
- Gulp v4 or higher
npm i -D gulp-tateru-cli
For further documentation about using tateru-cli, please look for its documentation. For further documentation about using Gulp, please look for its documentation.
For correct resolving destination through pipe, set options.ext
to empty string in tateru.config.json
.
{
"options": {
"data": {},
"src": "example/src/twig",
"ext": ""
}
}
You can find an example of a complete file in the fixtures: test/fixtures/tateru.config.json
.
const { src, dest } = require("gulp");
const { gulpTateruCli } = require("gulp-tateru-cli");
const build = function build() {
return src(["tateru.config.json"], {
cwd: ".",
})
.pipe(gulpTateruCli())
.pipe(dest("dist"));
};
Plugin gulp-tateru-cli supports TypeScript, so you can use type annotations in your gulp files for better type safety and developer experience.
const { src, dest } = require("gulp");
const { gulpTateruCli } = require("gulp-tateru-cli");
/** @type {import('gulp-tateru-cli').GulpTateruCliOptions} */
const options = {
env: "prod",
lang: "cs",
};
const build = function build() {
return src(["tateru.config.json"], {
cwd: ".",
})
.pipe(gulpTateruCli(options))
.pipe(dest("dist"));
};
const { src, dest } = require("gulp");
const { gulpTateruCli } = require("gulp-tateru-cli");
const { html, js } = require("js-beautify");
/** @type {import('gulp-tateru-cli').Formatter} */
const formatContents = (contents, fileType) => {
if (fileType && ["html", "xml"].includes(fileType)) {
return html(contents, {
indent_size: 4,
});
}
if (fileType && ["json", "webmanifest"].includes(fileType)) {
return js(contents, {
indent_size: 2,
});
}
return contents;
};
/** @type {import('gulp-tateru-cli').GulpTateruCliOptions} */
const options = {
formatter: formatContents,
};
const build = function build() {
return src(["tateru.config.json"], {
cwd: ".",
})
.pipe(gulpTateruCli(options))
.pipe(dest("dist"));
};
env?: 'prod' | 'dev' | string
Optional. The environment to use from tateru.config.json
. Example: dev
, prod
.
lang?: 'en' | 'cs' | string
Optional. The language to use from tateru.config.json
for the generated files. Example: 'en', 'fr', 'es', etc.
page?: 'homepage' | 'about' | string
Optional. The page to use from tateru.config.json
for the generated files. Example: 'home', 'about', 'contact', etc.
formatter?: (contents: string, fileType?: string) => string;
Optional. The formatter function to use for formatting the generated files, before minification.
contents
- The contents of the file to format.fileType
- The file type to minify. Example: 'html', 'json', 'webmanifest', etc.
minify?: (contents: string, fileType?: string) => string;
Optional. The minify function to use for minifying the generated files.
contents
- The contents of the file to minify.fileType
- The file type to minify. Example: 'html', 'json', 'webmanifest', etc.
Want to contribute? Feel free to open an issue or pull request on GitHub! 🚀 We welcome bug reports, feature requests, and code contributions.
- Fork the repo
- Create a new branch (
git checkout -b feature-branch
) - Make your changes
- Commit the changes (
git commit -m "Add new feature"
) - Push to the branch (
git push origin feature-branch
) - Open a pull request 🚀
If you have any questions or need help, feel free to open an issue on GitHub or contact me via GitHub profile.
MIT License © 2025 Daniel Sitek