Skip to content

Instantly share code, notes, and snippets.

@annevk
Created January 17, 2015 14:58
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 annevk/ee2c73152fa6f208f57f to your computer and use it in GitHub Desktop.
Save annevk/ee2c73152fa6f208f57f to your computer and use it in GitHub Desktop.
HTML macros

To be crystal clear, this is an idea, not a proposal.

The motivation is solving the custom element upgrade step through JavaScript, while also allowing other syntaxes to be mixed with HTML if so desired. The macro element generates a sequence of tokens that can be processed by JavaScript.

document.getMacro().then(function(macro) {
  // This should probably be asynchronous so large macros can be done incrementally
  for(let token of macro.tokens) {
    // Let's build a tree, or reparse tokens Markdown-style...
    ...
  }
}

...
<macro>
  <hi> <b> ... </b> </hi>
</macro>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment