Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Latest commit

 

History

History
48 lines (31 loc) · 1.23 KB

Klipse.md

File metadata and controls

48 lines (31 loc) · 1.23 KB

How to Klipsify an article

Basic steps

Having interactive code snippets in an article is straightforward. You need to:

  1. Add :klipse true in the map at the beginning of the article
  2. Instead of a clojure block, you make a klipse-clojure block and Boom the code snippet becomes interactive

Macros

Write macros in Klipse require using defmacro from https://github.com/mfikes/chivorcam, like this:

(require '[chivorcam.core :refer [defmacro defmacfn]])

You might want to hide this code snippet, by using HTML tags:

<pre style="visibility:hidden; height:0;"><code class="klipse-clojure">
(require '[chivorcam.core :refer [defmacro defmacfn]])
</code></pre>

Dealing with macros in Klipse is a bit cumbersome. You need to

  1. Define the macro in a namespaces whose name ends with $macros
  2. Use the macro with its fully-qualified names (without the $macros)

Imagine you want to create a macro named foo and use it in cljs.user namespace.

First, you switch to cljs.user$macros namespace to create the macro:

(ns cljs.user$macros)

(defmacro foo [m]
  m)

Then, you use the macro with its fully-qualified name cljs.user/foo, like this:

(ns cljs.user)

(cljs.user/foo 123)