prop maths: espace multiline strings

This commit is contained in:
jean-emmanuel 2018-02-14 10:01:16 +01:00
parent 4cfa779d5d
commit d5dad476f6
2 changed files with 8 additions and 0 deletions

View file

@ -289,8 +289,15 @@ class Widget extends EventEmitter {
try {
propValue = propValue.replace(/#\{(?:[^\}\\]|\\.)+\}/g, (m)=>{
// unescape brackets
m = m.replace(/\\(\{|\})/g, '$1')
// espace multiline strings
m = m.replace(/`([^`]*)`/g, (m)=>{
return m.replace(/"/g,'\\"').replace(/\n/g,'\\n').replace(/`/g,'"')
})
if (!this.parsers[m]) this.parsers[m] = math.compile(m.substr(2, m.length - 3).trim())
let r = this.parsers[m].eval(variables)