Very cool! You might also want to check out sparkler, which uses macros to let you do this with a little better syntax: https://github.com/natefaubion/sparkler
There's also matches.js, which is the deprecated precursor to sparkler: https://github.com/natefaubion/matches.js