I wanted to indent an actual rendered line of html. Does anybody know how to do this? It seems to overlook whitespace.

I tried including:

app.get('/blog' , function(req,res){
res.render('blog' , {pretty:true});
});

But it didn't fix the issue. Am I missing something?

有帮助吗?

解决方案

res.render's second argument passes a javascript object into the Jade view. Literally, you are passing a variable called pretty into the view, which has the value of true. It doesn't affect page formatting.

If you want to indent html output, you can either use  , or the pre html tag, which preserves spaces and line breaks (though the font displayed will be fixed-width).

Example for  

p
        This is an indented paragraph.
p
    This is not indented.

Example for <pre>

pre.
        This is an indented paragraph.
    This is not indented.


Edit:

Alternatively, you can also indent the first line in an element with CSS.

p {
    text-indent: 50px;
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top