Skip to content

Instantly share code, notes, and snippets.

@cgrand
Last active December 22, 2015 15:49
Show Gist options
  • Save cgrand/6494619 to your computer and use it in GitHub Desktop.
Save cgrand/6494619 to your computer and use it in GitHub Desktop.

You can use id attributes suffixed by # within your HTML template code in order to generate :#id# selectors that you can later use within Enlive template.

For example, if you say:

<div id="content-main#"></div>

You can later reference it with :#content-main# selector, which will be automatically generated for you.

One of the hidden benefist is that if your application code relies on some element in HTML, here it will be validated, and if there's anything referenced that's not present in HTML, you'll get a warning during compilation.

Such ids are automatically removed so duplicate ids won't show up in the output.

@ifesdjeen
Copy link

2 points:

  • I thought of something that would be completely unobtrusive with standard
  • If id# generates a symbol, you don't have to validate it again, and you'll get errors during compile time vs execution time (e.g. selector can't be matched)

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