Skip to content

Instantly share code, notes, and snippets.

@potch
Last active February 15, 2017 17:02
Show Gist options
  • Save potch/cc83a493121e272d19f8c06f1eae195e to your computer and use it in GitHub Desktop.
Save potch/cc83a493121e272d19f8c06f1eae195e to your computer and use it in GitHub Desktop.
PURE ES6 HTML TEMPLATING
let index = ({title, name}) => `
<h1>${title}</h1>
${name ? `
<h2>Hello, ${name}.</h2>
`:`
<a href="#">Log in here</a>
`}
<div>footer</div>
`;
document.querySelector('div').innerHTML = index({
title: 'cool page',
name: 'potch'
});
@potch
Copy link
Author

potch commented Feb 15, 2017

@asutherland is right! (of course). This is a super gross and way over-clever syntactic hack, and doesn't come close to replacing existing templating libraries, especially in terms of security of interpolated content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment