From 5519822ee7d95c1ad9a08a6ae93d6fbda7483625 Mon Sep 17 00:00:00 2001 From: Mike Thompson Date: Tue, 13 Feb 2018 10:24:20 +1100 Subject: [PATCH] Create an initial FAQ --- docs/FAQ/UsingAnEntity.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 docs/FAQ/UsingAnEntity.md diff --git a/docs/FAQ/UsingAnEntity.md b/docs/FAQ/UsingAnEntity.md new file mode 100644 index 0000000..25d4401 --- /dev/null +++ b/docs/FAQ/UsingAnEntity.md @@ -0,0 +1,33 @@ +### Question + +How can I use an entity like "nbsp"? + +### Answer + +If you try to do this: +```clj +[:div "hello" " " "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... + + ```clj + (:require [goog.string :as gstring]) + ``` + + 2. Use it like this ... + + ```clj + [:div "hello" (gstring/unescapeEntities " ") "there"] + ``` + +Note that `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`](https://www.npmjs.com/package/jsdom-global)). + +*** + +Up: [FAQ Index](README.md)