O'Reilly logo

Metaprogramming Elixir by Chris McCord

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required