nodejs, jade escape markup

后端 未结 5 1211
隐瞒了意图╮
隐瞒了意图╮ 2020-12-30 08:35

I have an Express app using the default Jade view engine. When I try to render HTML as-is in a

 element, it gets rendered as actual DOM elements inst         


        
5条回答
  •  梦毁少年i
    2020-12-30 09:17

    Actually the OP asks for the escaping, not the unescaping. Which I ran into today.

    Let assume, that you have varName variable with FooBar content.

    Then this template will use the escaped value:

    #foobar= varName
    

    so it becomes:

    <b>FooBar</b>

    If you use the bang operator:

    #foobar!= varName
    

    jade won't escape it, so it becomes:

    FooBar

提交回复
热议问题