Summary
In this chapter, we first learned what EEx
is. We covered several ways of using it, from dynamically evaluating a string to using a template file for a module’s compilation. We also learned about EEx.SmartEngine
, the default engine used by EEx
for templating. We wrote a custom engine, CustomEngine
, which used a marker that inspected the result of an element.
We then used all those concepts to update our HTTP server to return server-rendered HTML. We wrapped up by writing tests for our HTTP server and added Floki
, an HTML parser, to write tests that allow us to validate an HTML response and test the attributes of an element.
In the next chapter, we will add the logic to define view modules, which will make using templates easier by housing some shared helper functions made accessible in the templates.