Skip to main content
CSS is fun and cool and I like it.

What ya need there is a bit of templating

I had a fella write in to me the other day. He had some HTML, CSS, and JavaScript, and it just wasn’t behaving like he thought it ought to. The HTML had some placeholders in it and the JavaScript had some data in it, and the assumption was that the data would fill the placeholders.

To those of us with some degree of web knowledge, we can look at this and see why it’s not working like he thought it … Read article “What ya need there is a bit of templating”


A Follow-Up to PHP Templating

Not long ago, I posted about PHP templating in just PHP (which is basically HEREDOC syntax). I’m literally using that technique for some super basic templating I needed to do on this very WordPress site. The main pushback was that this kind of thing can be an XSS vulnerability. In my case, it’s not, because I’m not using it for anything other than an abstraction convenience for my own hand-written strings.

Since then, we’ve had a couple of good articles … Read article “A Follow-Up to PHP Templating”


PHP is A-OK for Templating

PHP templating often gets a bad rap for facilitating subpar code — but that doesn’t have to be the case. Let’s look at how PHP projects can enforce a basic Model, View, Controller (MVC) structure without depending on a purpose-built templating engine.… Read article “PHP is A-OK for Templating”


HTML Templates via JavaScript Template Literals

You know those super cool backticks-for-strings in new JavaScript?

let emotion = `happy`;
let sentence = `Chris is feeling ${emotion}`;

Besides the variable interpolation in there being mighty handy, the do multi-line strings wonderfully, making them great for chunks of HTML:

const some_html = `
  <div class="module">
Read article “HTML Templates via JavaScript Template Literals”

Four Killer Features of Nunjucks

Nunjucks calls itself “A rich and powerful templating language for JavaScript”, which sounds about right. It’s not intentionally super lightweight like Mustache or the slightly more robust (but still pretty light) Handlebars. It’s a full-on language, packed with all kinds of stuff you might want when writing templates.

You can run it in the browser, but you probably shouldn’t. This is meant to be run in Node.js and used to compile templates server side.

In other words: it’s a … Read article “Four Killer Features of Nunjucks”


Getting Started with CSS Modules

There isn’t one single approach with CSS Modules to making the JavaScript templates, the CSS files, or the build steps to make them work. In this post, which is part of a series on CSS Modules, we’ll look at one approach. The goal of this post is to get a CSS Modules project up and running.

Article Series:

  1. What are CSS Modules and why do we need them?
  2. Getting Started with CSS Modules (You are here!)
  3. React + CSS Modules
Read article “Getting Started with CSS Modules”