encode javascript for a jade template

I am trying to pass a .js file to a jade template to have it render inside an ACE editor. But for some files (may have regex and other escaped characters) the editor will not render and I get errors in the browser, how should I encode/escape the file so that it is always rendered correctly? I have tried encode/decodeURIcomponent... I guess it's Jade that is causing the issue.

Or should I just try sending the file after the page renders and not have it expand as part of the template?

Server:

editFile = fs.readFileSync(fileName, 'utf8'); //JavaScript file
res.render('editor', { title: 'File Editor '+fileName, editFile: editFile });

Jade template:

#editor
script(src='/ace/ace.js', type='text/javascript', charset='utf-8')
script(type='text/javascript', charset='utf-8').
var fileContent = '!{editFile}';
var editor = ace.edit("editor"); //standard div
editor.getSession().setMode("ace/mode/javascript");
editor.setValue(fileContent);

So the solution seems to be to be:

var fileContent = !{JSON.stringify(editFile)};

Thanks All.