Create an initial FAQ

This commit is contained in:
Mike Thompson 2018-02-13 10:24:20 +11:00 committed by GitHub
parent 464d372a58
commit 5519822ee7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 0 deletions

33
docs/FAQ/UsingAnEntity.md Normal file
View File

@ -0,0 +1,33 @@
### Question
How can I use an entity like "nbsp"?
### Answer
If you try to do this:
```clj
[: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...
```clj
(:require [goog.string :as gstring])
```
2. Use it like this ...
```clj
[:div "hello" (gstring/unescapeEntities "&nbsp;") "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)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;