Creating a Template Engine Part 2: The Code

Last time we ripped off a bunch of libraries to create a string interpolation script and explained the composite pattern with a view to ultimately being able to parse and populate this template: <ul> ${#if responses.length} ${#each responses as response} <li>${response.name}</li> ${#end each} ${#end if} ${#if !responses.length} <li><em>No responses</em></li> ${#end if} </ul> If you don’t […]

Creating a Template Engine Part 1: Groundwork

Although I strongly recommend using a popular, well tested engine, I believe that creating your own is a great learning experience. Since I’ve recently done this and couldn’t find any blog posts explaining the process, I thought I’d take the time to explain how one works, hopefully teaching a few budding JavaScripters looking to expand […]