rum

Simple, decomplected, isomorphic HTML UI library for Clojure and ClojureScript | 0.12.8 https://github.com/tonsky/rum/blob/gh-pages/CHANGELOG.md#0128
grounded_sage 2018-08-07T03:28:21.000122Z

Is there a simple way to escape html? I seem to be overlooking something in Rum I think

grounded_sage 2018-08-07T03:38:38.000040Z

I'd like to use an svg

<svg width="96" height="96" viewBox="0 0 96 96" fill="none" xmlns="http://www.w3.org/2000/svg">}}]])
<circle cx="32.5" cy="32.5" r="31" transform="translate(16)" stroke="#BF9C8C" stroke-width="3"/>
<circle cx="32.5" cy="32.5" r="31" transform="translate(16 31)" stroke="#BF9C8C" stroke-width="3"/>
<circle cx="32.5" cy="32.5" r="31" transform="translate(0 15)" stroke="#BF9C8C" stroke-width="3"/>
<circle cx="32.5" cy="32.5" r="31" transform="translate(31 15)" stroke="#BF9C8C" stroke-width="3"/>
</svg>
with no manual escaping or converting to hiccup syntax.

mattly 2018-08-07T04:29:23.000073Z

is that code in a variable somewhere?

mattly 2018-08-07T04:30:19.000156Z

like, as a string?

mattly 2018-08-07T04:30:47.000011Z

you can do [:div {:dangerouslySetInnerHTML {:__html my-svg}}]

mattly 2018-08-07T04:31:00.000044Z

this is more of a react thing

mattly 2018-08-07T04:31:15.000093Z

one does not simply splice a string into the virtual dom

mattly 2018-08-07T04:31:47.000027Z

a better method would be to either

mattly 2018-08-07T04:31:58.000028Z

1. make the svg available over HTML and use an img tag

mattly 2018-08-07T04:32:16.000028Z

2. base64-encode it in CSS and have it be a background-image on some id or class

mattly 2018-08-07T04:34:54.000012Z

anyway, see this: https://reactjs.org/docs/dom-elements.html#dangerouslysetinnerhtml

grounded_sage 2018-08-07T05:25:21.000082Z

It appears to exhibit the same behaviour whether in a def or or inline. I did to it in a previous project (with manual escaping) as I was using inline svg and symbols to split the svg into reusable components that were composed in different ways throughout the page. It’s better for performance as it’s streamed with HTML and reduces extra requests.

grounded_sage 2018-08-07T05:26:11.000097Z

cc @mattly

euccastro 2018-08-07T23:45:44.000111Z

@grounded_sage why not convert them to hiccup syntax? you could still render them and compose them at the server side. also, if you're going to have a react app, then you're going to ship your JS code anyway, so you could alternatively build your SVG there and it wouldn't cost any extra requests