Jade - 在一行中打印多个变量
Jade - Print many variables in one line
我正在尝试打印从控制器传递过来的几个变量,以便在一行中查看。
变量的内容类似于 "xyz",其中标签是有效的 html 标签。
我现在正在做的是 -
div
!= (notification.content + notification._.publishedDate.format('MMMM Do, YYYY'))
但是这会在两行上打印 div。
生成的html内容为-
<div>
<p>School is closed tomorrow <a href="http://www.booking.com">link</a></p>
March 7th, 2016
</div>
另外我做不到 -
p= (notification.content + notification._.publishedDate.format('MMMM Do, YYYY'))
因为输出是这样 HTML -
<p><p>School is closed tomorrow&nbsp;<a href="http://www.booking.com">link</a></p>March 7th, 2016</p>
嗨!
使用 Jade/HTML 查看一些显示消息的方法。
请测试这些方法并在您的项目中使用最好的:
声明变量
// Variable with `<p></p>`
- var notification = {content: '<p>School is closed tomorrow <a href="http://www.booking.com">link</a></p>', publishedDate: '2016-03-07'}
// Variable withOUT `<p></p>`
- var test = {content: 'The message <a href="#">link</a>', publishedDate: '2016-03-07'}
1) Return 转义文本
div #{notification.content} #{notification.publishedDate}
// Return | escaped string:
// <p>School is closed tomorrow <a href="http://www.booking.com">link</a></p> 2016-03-07
2) Return HTML 代码(未转义 | 真实标签)
div !{notification.content} !{notification.publishedDate}
// Return | unescaped (2 lines)
// School is closed tomorrow link
// 2016-03-07
3) Return HTML 内联代码(也未转义)
您需要修改数组条目。请参阅上面的 var "test"(关于声明变量):
div: p !{test.content} !{test.publishedDate}
// Return | unescaped (1 line)
// The message link 2016-03-07
如果适合您,请尝试应用您自己的变量和规则。
我正在学习 Jade。希望能帮到你。
- 有什么问题可以评论或者私聊我@devromulobastos
我正在尝试打印从控制器传递过来的几个变量,以便在一行中查看。
变量的内容类似于 "xyz",其中标签是有效的 html 标签。
我现在正在做的是 -
div
!= (notification.content + notification._.publishedDate.format('MMMM Do, YYYY'))
但是这会在两行上打印 div。
生成的html内容为-
<div>
<p>School is closed tomorrow <a href="http://www.booking.com">link</a></p>
March 7th, 2016
</div>
另外我做不到 -
p= (notification.content + notification._.publishedDate.format('MMMM Do, YYYY'))
因为输出是这样 HTML -
<p><p>School is closed tomorrow&nbsp;<a href="http://www.booking.com">link</a></p>March 7th, 2016</p>
嗨!
使用 Jade/HTML 查看一些显示消息的方法。
请测试这些方法并在您的项目中使用最好的:
声明变量
// Variable with `<p></p>`
- var notification = {content: '<p>School is closed tomorrow <a href="http://www.booking.com">link</a></p>', publishedDate: '2016-03-07'}
// Variable withOUT `<p></p>`
- var test = {content: 'The message <a href="#">link</a>', publishedDate: '2016-03-07'}
1) Return 转义文本
div #{notification.content} #{notification.publishedDate}
// Return | escaped string:
// <p>School is closed tomorrow <a href="http://www.booking.com">link</a></p> 2016-03-07
2) Return HTML 代码(未转义 | 真实标签)
div !{notification.content} !{notification.publishedDate}
// Return | unescaped (2 lines)
// School is closed tomorrow link
// 2016-03-07
3) Return HTML 内联代码(也未转义)
您需要修改数组条目。请参阅上面的 var "test"(关于声明变量):
div: p !{test.content} !{test.publishedDate}
// Return | unescaped (1 line)
// The message link 2016-03-07
如果适合您,请尝试应用您自己的变量和规则。
我正在学习 Jade。希望能帮到你。
- 有什么问题可以评论或者私聊我@devromulobastos