[Jade] Mixin Naming Conventions

Tadashi Shigeoka ·  Sun, April 5, 2015

Jade has a feature called mixins that allows you to modularize templates.

You can call templates in a method-like way with +hoge(arg), and since it’s method-like, I was curious about the naming conventions and did some light research.

Below is sample code from Jade:

mixin dialog-title(title)
  .dialog
    h1= title
    p stuff

It wasn’t using snake_case or lowerCamelCase, but instead used hyphens as separators, defined as dialog-title.

Let’s also look at .jade files:

As seen with extend-layout.jade, file names also use hyphens as separators.

Using hyphen-separated naming for Jade mixins seems like a good approach since it won’t conflict with JavaScript method naming conventions, making it easier to grep.

That’s all from the Gemba.