Category: Programming

I’ve been programming with Elixir for the last two years now, and while at first it seemed like my knowledge of Ruby on Rails would carry over to using Phoenix, that’s only true at the surface level. Here are some resources that help me the most for learning Elixir.

There are many examples online of looping through lists in a Phoenix template, but I came across an instance where I needed to loop over a map. I wanted the same clean for items <- items do syntax. After a bit of research, I found this for loop is actually considered a comprehension.

When looping through a map, you can simply create a tuple with two arguments {key, value}.

While the Magento 2 adoption of KnockoutJS has opened up the possibility for modern front-end features, the level of abstraction has raised new challenges. Adding a placeholder to form fields is no longer as simple as opening the template file for the form. Here I will explain the steps for adding placeholders to Magento 2 fields.

The inputs_for method comes with two options for rendering the page with new elements as part of the collection you’re modifying (if it is a collection). For example, if you’re creating a to-do list that has a number of items, you could use the options like so:

If we already have items in the collection, inputs_for will iterate and fill the fields with the appropriate values, then append the new entry to the end, or in the case of prepend it will add the new entry to the beginning of the collection.