Support the Entire HTML Spec with Macros

We’re off to a great start, but our goal is to create a first-class DSL. A single tag macro simply won’t cut it. Let’s up our sophistication by supporting all 117 valid HTML tags. We could write a hundred macros by hand, but let’s use the techniques you learned in Chapter 3, Advanced Compile-Time Code Generation, to save time and effort.

As before, a quick Internet search turned up a complete list of HTML tags.[9] After a copy and paste into a flat text file, we end with a file of line-delimited tags. Here’s a handful of lines from the file:

html/lib/tags.txt
 
form
 
frame
 
frameset
 
h1
 
head
 
header

We’ll use this file to generate the entire HTML spec. Copy the file over to your own project and save it ...

Get Metaprogramming Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.