Look at example.js
It bases the indentation of the second line of the template literal.
Make sure you put the m in front of it!
| import m from 'multiline-templiteral.js'; | |
| console.log(m`hey there | |
| this is a multiline | |
| ${"expressions work to".toUpperCase()}`) | |
| // is equivalent to | |
| `hey there | |
| this is a multiline | |
| EXPRESSIONS WORK TO` |
| function m(strings,...reps) { | |
| let lines = strings.reduce((str, cur, i) => str + cur + (reps[i] || ""), "").split("\n"); | |
| let ws = new RegExp(`^${/^(\s+)/.exec(lines[1])[0]}`); | |
| return lines.map(line => line.replace(ws, "")).join("\n"); | |
| } | |
| try{export m as default}catch(e){try{module.exports=m}catch(r){}} |