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

Further Exploration

You leveled up on your metaprogramming skills by defining a language within a language using DSLs. This style of problem solving will let you create expressive libraries that can distill a problem into a natural set of macros. You saw how some domains, like HTML generation, fall naturally into a DSL, while others require careful consideration of tradeoffs. Think about other ways you can extend the HTML DSL to make it production ready. Here are some ideas to get you started:

  • Extend the Html library with nicely formatted output:

 
iex>​ Template.render
 
"<div id=\"main\">
 
<h1 class=\"title\">Welcome!</h1>
 
</div>
 
<div class=\"row\">
 
<div>
 
<p>Hello!</p>
 
</div>
 
</div>"
  • Sanitize all text input against ...

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