Mandarin + Forage - An admin tool for phoenix

One of the things I love the most about such tools for Elixir is that the new source manipulation features allow for limited changes to AST and source code (and sometimes pretty complex changes!).

I have tried to develop a solution for that: CodeGen - simple, succint and customizable code generation for your libraries. This library should only generate the code you ask it to generate, and keep the rest as a hidden AST. You can dynamically ask the library to dump the source code of a given group of functions in the module’s source code. I believe it would be interesting to convert Mandarin into something that uses this.

Oh, but I am not using webpack at all! I am using a much more “interesting” solution. I’ve written a script that downloads the bootstrap theme and the “standard” bootswatch themes (which work well with default bootstrap classes without any customizations and can be swapped with each other) and after downloading the files uses Regexs to “parse” critical parts of the CSS file contents, namely the highlight colors. Then, using the colors it has extracted from the file I build a new CSS class for validated/unvalidated forms and insert it into the minified CSS. Everything is done in Elixir, of course. The generated CSS files modified in such a way are then shipped by the library and can be served directly as static assets. This is either very cool or totally horrifying, but I prefer the first interpretation.

1 Like