翡翠从string格式问题的HTML
我正在尝试渲染存储在mongodb中的一段HTML(由TinyMCE创build),稍后由jade渲染。
这是我的post.content
string,从console.log
显示:
<p>Well, I'll tell you about that...</p><p>Sometimes, we are just not sure about these things <span id="_mce_caret" data-mce-bogus="1" style=""><strong>Until we get some formatting!!!!</strong></span></p>
我期待它看起来像这样:
那么,我会告诉你…
有时,我们只是不确定这些事情, 直到我们得到一些格式化!
这就是我所看到的(从Chrome复制):
我在这是要干嘛?
<
那么,我会告诉你…
有时,我们只是不确定这些事情, 直到我们得到一些格式化!
>好吧,我会告诉你…
有时,我们只是不确定这些事情, 直到我们得到一些格式化!
>
这是我的玉模板的相关部分:
.container.content h2 #{post.title} hr div #{post.content}
我究竟做错了什么?
显然是UTF-8字节顺序标记…它指向一个格式问题,但我没有看到任何地方我说任何关于格式或改变格式。 在一件事情中出现也是没有意义的。 也不会导致console.log的问题。 至于它重复了两次,我相当迷惑。 也许我写了我的模板是错的?
你有没有试过@马库斯·艾克沃尔说的? 似乎工作正常。
首先你的testing数据:
{ post: [ {title: "<p>Well, I'll tell you about that...</p>", content: '<p>Sometimes, we are just not sure about these things <span id="_mce_caret" data-mce-bogus="1" style=""> <strong>Until we get some formatting!!!!</strong> </span> </p>'}] }
接下来的玉器加价:
.container.content h2 !{post[0].title} hr div !{post[0].content}
至less是HTML输出:
<div class="container content"> <h2><p>Well, I'll tell you about that...</p></h2> <hr/> <div> <p> Sometimes, we are just not sure about these things <span id="_mce_caret" data-mce-bogus="1" style=""> <strong>Until we get some formatting!!!!</strong> </span> </p> </div> </div>
和一个工作jsFiddle 。