Safehou-se (Pt 2)

HomeBlog


A lot of changes were made in the past two days. I added the ability for users to specify input types in their code templates, which was most useful for color fields as users could now directly select colors as opposed to having to find the exact hex code first. Secondly, a major overhaul was done on the model I was using for Safehou-se templates.

The major overhaul was done mostly to support loop variables. The format I had before of a List and then a Map pointing to indices in the list was... not the best thought out implementation. Instead, I took some inspiration from template engines such as jinja2 or Tera and created a very basic template model. While in the future, I believe it'll be possible to make the template recursive, it currently is not.

The current model keeps a Map of both regular variables and "loop" variables, which are just another Map of variables specific to that loop. The Map, rather than using indices, now just keeps track of what String value needs to be replaced and the current replacement value.