Revving Up View Engines
Welcome to the Body Shop
Section titled “Welcome to the Body Shop”When we’re doing any server-side generation of HTML, we could build up fragments with brutish string concatenation. But that’s like duct-taping a bumper onto a Ferrari. It works, but it’s ugly, dangerous, and prone to error.
Instead, we use a templating engine. This handles the string interpolation for us, allowing us to “skin” our data with high-performance HTML bodies.
There are many options on the market, each with its own tuning specs:
But for our fleet, we’ll be working primarily with the venerable EJS (Embedded JavaScript). Why? Because it’s classic, reliable, and handles like a dream (although the syntax is a bit ugly and dated).
Fig 1: The EJS Engine—high octane data injection.
VSCode EJS Formatting Extension
Section titled “VSCode EJS Formatting Extension”EJS syntax is likely going to mess with our code formatting extensions.
Quick Fix: EJS Language Support
Section titled “Quick Fix: EJS Language Support”There is a specific extension that helps VSCode understand the <% %> syntax so it stops screaming at you.
Install it, and your editor will stop flagging valid EJS tags as errors.
Extra Bits & Bytes
Section titled “Extra Bits & Bytes”EJS Docs From the Source