Digests » 328

this week's favorite

Anti-pattern multi-clause functions

In Elixir, we can use multi-clause functions to group functions together using the same name. One possible advantage of doing this is minimising the code surface area of our modules. It’s also supposed to keep our functions more focused and organised when done correctly.

Adding Bulma to Phoenix 1.6

In this tutorial I'll go over how to set up Sass processing for your Phoenix 1.6 app, how to install Bulma using Mix, and then how to import Bulma into your main SCSS file for you to use and customize. For those who just want to see the code, you can check the phoenix-bulma repository that contains the final code from this tutorial.

Adding Tailwind CSS to Phoenix 1.6

Over the years, Tailwind CSS has become my go-to CSS framework. I previously wrote a tutorial on how I add Tailwind to Phoenix 1.4 and 1.5 apps which use webpack by default. Phoenix 1.6, however, uses esbuild rather than webpack by default. Although many of the steps to installing Tailwind remain the same, enough is different to warrant a new tutorial.

Under the hood of macros in Elixir

As discussed in the previous post, macros are compile-time constructs in Elixir. So, before diving into how macros work, it is important to understand where macros lie within Elixir’s compilation process.

Preparing a Phoenix 1.6 app for deployment with Elixir Releases

When deploying to production is better to inject runtime info to the application when it starts instead of having that info hardcoded in the source code. We pass info to the app to affect the way it works depending on the environment we are deploying the app to (e.g. staging, production).