increpare / PuzzleScript

Open Source HTML5 Puzzle Game Engine
MIT License
903 stars 159 forks source link

why is $ escaped and how does it make sense? #839

Closed increpare closed 2 years ago

increpare commented 2 years ago

explain this to yourself better (in buildstandalone.js) " // $ has special meaning to JavaScript's String.replace ($0, $1, etc.) Escape $ as $$. sourceCode = sourceCode.replace(/\$/g, '$$$$');

htmlString = htmlString.replace(/__GAMEDAT__/g,sourceCode);

"

increpare commented 2 years ago

explanation added in https://github.com/increpare/PuzzleScript/commit/a7cd1534a90bc0288c58c2baaf1d720c7167572b