Adrian Mouat
Adrian Mouat

Reputation: 46480

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.

Upvotes: 12

Views: 2845

Answers (2)

Daniel Szmulewicz
Daniel Szmulewicz

Reputation: 3961

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 " ")

Upvotes: 23

Adrian Mouat
Adrian Mouat

Reputation: 46480

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.

Upvotes: 8

Related Questions