Bug 911373 - Improve shared/js/template.js's escaping logic

`make lint` passes.
Waiting to see if other tests will pass.
you need to change the `rentity` variable above too.

hint: you'll need to change the unit tests in `apps/sharedtest/test/unit/template_test.js` because some tests use the `/` character ;)