ClojureScript and HTML entities

◇◆丶佛笑我妖孽 提交于 2019-12-18 19:45:08

问题


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.


回答1:


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



回答2:


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.



来源:https://stackoverflow.com/questions/14408377/clojurescript-and-html-entities

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!