Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ClojureScript and HTML entities

I'm having trouble getting a non-breaking space into HTML via ClojureScript.

If I use " " the string is simply printed literally.

I'm using the Crate library.

like image 346
Adrian Mouat Avatar asked Jan 18 '13 22:01

Adrian Mouat


2 Answers

Google's closure library that clojurescript leverages includes string helpers that will allow you to expand HTML entities.

(require '[goog.string :as gstring])
(gstring/unescapeEntities " ")
like image 109
Daniel Szmulewicz Avatar answered Sep 20 '22 13:09

Daniel Szmulewicz


Got it after reading:

https://github.com/ibdknox/crate/issues/12

Basically, the issue seems to be that Crate inserts directly into the DOM thus skipping entity expansion (please someone correct me if I've misunderstood).

One solution is to use the following string which represents the UTF for &nbsp: \u00A0.

like image 28
Adrian Mouat Avatar answered Sep 19 '22 13:09

Adrian Mouat