chapter three

3 Building a Mad Libs Template Engine

 

This chapter covers:

  • Incorporating multiple providers in a single project
  • Parameterizing configuration files with input variables
  • Usage of interpolation functions within template files
  • Validating and transforming data with expressions and functions
  • Creating dynamic Terraform configurations with count

Mad Libs, in case you don’t know, is a phrasal templating word game in which one player prompts another for words to fill in the blanks of a story, before reading the (often zany) story aloud. If you’ve ever played Apples to Apples or Cards against Humanity, it’s a lot like that except with a whole story rather than a single sentence or two. What makes these kinds of games funny is the juxtaposition that exists between an otherwise normal story, and the odd words chosen to fill in the blanks.

3.1   First Attempt at Mad Libs

3.2   Making the Word Pool

3.3   Shuffling the Words

3.4   Using Template Data Sources

3.5   Outputting to a Local File

3.6   Improving Mad Libs with Expressions

3.7   Getting Fancy with For Expressions

3.7.1   Implicit Dependencies

3.8   Scaling Resources by Incrementing Count

3.8.1   A Better Way to Template

3.11   Overview

3.12   Summary