Fork me on GitHub
#deps-new
<
2020-12-27
>
FiVo12:12:31

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.

FiVo13:12:48

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.

FiVo13:12:41

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?

FiVo13:12:40

I have been thinking of using something like clojure.tools.namespace.move 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?

seancorfield20:12:03

@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: https://github.com/luminus-framework/luminus-template/tree/master/resources/leiningen/new/luminus (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.

FiVo22:12:04

@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.

seancorfield23:12:46

@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.