IHP 1.3 is out now!

Code Generator dark magic

Gonzalo Muñoz

So I've been trying to follow the docs to make the blog demo, and something caught my attention: there's a code generator, which using only the prompt "Posts" spat out a whole component, pagination included... And I'm in total awe, but also puzzled. I'm guessing there is a list of some pre-built templates for specific types of components, but I'm not seeing an index or a guide anywhere. Could you tell me what exactly is possible to do with the code generator? Or maybe point me in the right direction if I missed the docs on that. Thanks!

Zac Wood BUSINESS

The code for the different code generators can be found in IHP/IDE/CodeGen. Here's the code for generating a controller: https://github.com/digitallyinduced/ihp/blob/master/IHP/IDE/CodeGen/ControllerGenerator.hs

By design, IHP has strong conventions for how controllers and views are organized. This allows the code generator to create good defaults by simply copying in the name you inputted into a predefined format. It might look like magic, but all that's going on is IHP takes the name "Posts", puts it in a bunch of strings, and saves them in the conventional file format!

Gonzalo Muñoz

I see. So there's no fixed amount of components then, just good ol' heuristics. I'm loving this more by the minute.