Liking cljdoc? Tell your friends :D

Question

How can I use an entity like "nbsp"?

Answer

If you try to do this:

[:div "hello" "&nbsp;" "there"]     ;; <--- note: attempt to use an entity

then you will see the string for the entity. Which is not what you want.

Instead you should do this:

  1. Require in goog's string module...
(:require [goog.string :as gstring])
  1. Use it like this ...
 [:div "hello" (gstring/unescapeEntities "&nbsp;") "there"]

Note: unescapeEntities relies on the DOM to produce a string with unescape entities; in nodejs the DOM is unlikely to be available (unless you try using jsdom).


Up: FAQ Index      

Can you improve this documentation? These fine people already did:
Daniel Compton & Juho Teperi
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close