This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-03-28
Channels
- # aatree (1)
- # admin-announcements (5)
- # beginners (5)
- # braid-chat (2)
- # cbus (2)
- # cljs-dev (8)
- # cljsrn (13)
- # clojure (101)
- # clojure-chicago (1)
- # clojure-greece (11)
- # clojure-russia (77)
- # clojure-taiwan (1)
- # clojure-uk (5)
- # clojurescript (73)
- # core-async (5)
- # core-matrix (1)
- # cursive (5)
- # datomic (10)
- # devcards (44)
- # emacs (16)
- # hoplon (207)
- # keechma (5)
- # lein-figwheel (1)
- # leiningen (5)
- # liberator (3)
- # melbourne (1)
- # om (171)
- # onyx (25)
- # parinfer (1)
- # proton (2)
- # re-frame (28)
- # reagent (50)
- # untangled (7)
- # yada (4)
I'm trying to write a macro to demonstrate svg-code in a defcard-rg
. Being a macro noob I have a problem: how to insert the cord into the description-string.
the lower part executes the supplied code correctly, but I'm not sure how to display the code
in the description
@mmeix: (str " '''" ~code "'''")
'
= your backticks
for slack formatting
@mmeix: you probably want to wrap ~code
in a sablono html
macro?
depending on what you want to display
or you just want to present the code as a string?
(defmacro code-demo
[cardname svg-height code]
`(defcard-rg ~cardname
(str "'''" ~code "'''")
[:svg {:width "100%" :height ~svg-height}
~code]))
(macroexpand '(code-demo example 120 [:circle {:cx 12 :cy 20 :r 7}]))
;; =>
(cellophane.dom-test/defcard-rg example
(clojure.core/str "'''" [:circle {:cx 12, :cy 20, :r 7}] "'''")
[:svg {:width "100%", :height 120} [:circle {:cx 12, :cy 20, :r 7}]])
seems OK to me?
it seems, that the usage of backticks in devcard
's markdown format for description strings collides somehow with using them in a macro ...
it shouldn't, if they are in a string
isn't that what you wanted?
I think I know what's the problem
use (str "'''\n" ~code "\n'''")
probably needs the line breaks
doesn't seem right
as in, it should work
maybe it's the double usage of backticks, maybe they are not eval'd correctly in this case, sort of a corner case
shouldn't be
not really