kit-clj / kit

Lightweight, modular framework for scalable web development in Clojure
https://kit-clj.github.io/
MIT License
476 stars 44 forks source link

What is the purpose of snippets? #61

Open markokocic opened 2 years ago

markokocic commented 2 years ago

What are snippets? I see the reference in the source, but no documentation or examples. The snippets repository is also missing.

nikolap commented 2 years ago

Think these are still in development. @yogthos can comment more

yogthos commented 2 years ago

So, the idea behind snippets is to create templates that can be used to generate code in the REPL. An example snippet can be found here. The example snippet creates a Reitit route and handles all the boilerplate for it. Ideally this could works as sort of a curated Stack Overflow in the REPL. You could search for a snippet by tags or description, and then run the snippet to generate the code you need.

The snippet is a Markdown file that has to have the structure seen in the example where it declares tags, description, and a snippet. The arguments to the snippet get passed in when the snippet is called and injected in the template that's then rendered.

I was thinking of managing snippets in a similar way to modules where they could live in a repo and then new snippets can be added via pull requests.