Skip to content

Instantly share code, notes, and snippets.

@zaiste
Created March 4, 2020 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zaiste/5378fafa0bfc7c6fefa50f810dd9a3ac to your computer and use it in GitHub Desktop.
Save zaiste/5378fafa0bfc7c6fefa50f810dd9a3ac to your computer and use it in GitHub Desktop.
Fun with Pure Engine
const { compile } = require('pure-engine')
const escape = require('escape-html')
const fs = require('fs-extra');
async function example() {
const content = await fs.readFile('./index.html');
const { template } = await compile(content.toString())
console.log(template({ foo: 'bar' }, escape))
}
example()
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<!-- -->
</body>
</html>
<import layout from="./default.html" />
<layout>
<h1>Hello, world!</h1>
<form>
<input name="foo" />
<button>Submit</button>
</form>
</layout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment