Multiline strings that don't break indentation

前端 未结 5 1404
离开以前
离开以前 2020-12-30 18:32

According to this esdiscuss discussion, it is possible in ECMAScript 6 to define multiline strings without having to place subsequent lines of the string at the very beginni

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-30 19:07

    As Šime Vidas states, functions can be used as a tag, and invoked by just placing it in front of the template string.

    A number of NPM modules exist to do this, and will cover many edge cases that would be hard to cover yourself. The main two are:

    dedent, 4 million weekly downloads, last updated 4 years ago

    endent, 2.5 thousand weekly downloads, updated 4 months ago

提交回复
热议问题