How to trigger a new line in jade/pug?

对着背影说爱祢 提交于 2020-03-03 18:26:11

问题


I want to write several object attributes in a singular table tab each on a new line

here's my pug table code excerpt

table#posts(style="float:right; border: 1px solid green")
        tbody  
            each post in data
                 tr
                    td(style="border: 1px solid green")='Name: ' + post.firstname + ' ' + post.lastname  + 'Date of Birth: ' + post.dob
                    td(style="border: 1px solid green") buttons                    
            else
                 tr  
                    td No posts!

I want the new line to be between the Name and date of birth. Any help is appreciated, thank you!


回答1:


Add a <br /> tag

table#posts(style="float:right; border: 1px solid green")
        tbody  
            each post in data
                 tr
                    td(style="border: 1px solid green")
                      | Name: #{post.firstname + ' ' + post.lastname}
                      br
                      | Date of Birth: #{post.dob}
                    td(style="border: 1px solid green") buttons                    
            else
                 tr  
                    td No posts!

You can also enclose name and date of birth text within a <p> tag




回答2:


Put the text on a new line with a preceding |:

table#posts(style="float:right; border: 1px solid green")
        tbody  
            each post in data
                 tr
                    td(style="border: 1px solid green")
                      | 'Name: ' + post.firstname + ' ' + post.lastname
                      br
                      | 'Date of Birth: ' + post.dob
                    td(style="border: 1px solid green") buttons                    
            else
                 tr  
                    td No posts!


来源:https://stackoverflow.com/questions/49675099/how-to-trigger-a-new-line-in-jade-pug

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