Skip to content

Instantly share code, notes, and snippets.

@zachleat
Created September 11, 2020 23:03
Show Gist options
  • Save zachleat/dd68700493492517ae718c2f148debc2 to your computer and use it in GitHub Desktop.
Save zachleat/dd68700493492517ae718c2f148debc2 to your computer and use it in GitHub Desktop.
Pretend PHP in Eleventy with Nunjucks
// .eleventy.js
let Nunjucks = require("nunjucks");
module.exports = function(eleventyConfig) {
let env = Nunjucks.configure(".", {
tags: {
blockStart: '<?php',
blockEnd: '?>',
}
});
eleventyConfig.setLibrary("njk", env);
eleventyConfig.addShortcode("echo", function(str) {
return str;
})
};
// test.njk
hi
<?php if true ?>
hi again
<?php endif ?>
<?php echo "test" ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment