Created
September 11, 2020 23:03
-
-
Save zachleat/dd68700493492517ae718c2f148debc2 to your computer and use it in GitHub Desktop.
Pretend PHP in Eleventy with Nunjucks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// .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