Fork me on GitHub

Hey, I have a couple of questions concerning templates. Suppose I have some project which I would like to turn into clj-template. It has quite a few namespaces. Currently it's just simple deps.edn project.


I looked at the app and lib template and they only contain two clojure files. If my app contains quite a few files is there a way to keep most of the structure without doing so explicitly for every namespace. Essentially I would just like to replace the prefix of every namespace with the app name.


What is the usual workflow when working on a template? Do people just modify it then create a new project based off that template once they want to test it? Is there no way to just keep working on the template without the back and forth of generating a project when I want to test it? Maybe I misunderstood something in that regard?


I have been thinking of using something like or mranderson to just rename and move the namespaces in question when generating a new project based on the template, so I can still keep working "as usual" on the template. Is that a bad idea?


@finn.volkel I'm not entirely sure what you're asking about here. The built-in templates are very simple and it's easy enough to have all the template files in a single folder. Most real templates look a lot more like the projects they generate, or at least are organized into folders for related functionality within the template. See the Luminus template, for example: (that's just the template source files). The "template driver" -- the code that actually generates projects from template source files -- can be as simple or as complex as you want.


@seancorfield I think the main question is if there is there is way to keep working on the template files, containing for example mustache template logic, while also at the same being hooked into a repl session, so that one can test the code I write in the template source files. As I am assuming this is currently not possible, I am wondering what workflow people usually have when working on the template source files. Hope this makes sense now.


@finn.volkel I don't know what workflow people use. I have never actually created any templates. The ones in clj-new come directly from boot-clj, with just very minor updates (to use deps.edn instead of build.boot) and those in turn I copied from lein-new (again, with just a minor update from project.clj to build.boot). I don't use templates either, except for the very basic built-in ones.