Skip to content

Commit

Permalink
Expand on the plan for unescaping a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikermcneil committed Mar 31, 2016
1 parent 1431b33 commit 41d47ca
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/hooks/views/html-scriptify.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ module.exports = function htmlScriptify(options){
}

// console.log('options.data',options.data);
console.log('_.keys(options.data)',_.keys(options.data));
// console.log('_.keys(options.data)',_.keys(options.data));

// Build and return HTML to inject.
var html = '<script type="text/javascript">';
Expand All @@ -96,9 +96,17 @@ module.exports = function htmlScriptify(options){
// (see https://github.com/lodash/lodash/blob/4.7.0/dist/lodash.js#L14038)
// Except it also has to be recursive. But luckily, we don't have to worry
// about circular references, since we know this was just serialized.
//
// TODO: implement
html += ' var unescape = ' + (function (u){ /* TODO */ return u; }).toString() + '; ';
html += ' var unescape = ' + (function clientSideUnescapeFn(escapedValue){
var unescapedValue = escapedValue;
// TODO: actually unescape it
//
// This may kind of suck because it needs to be vanilla JS.
// Not planning on any kind of special backwards-compatible support for older browsers,
// but if that IS needed, or any other customizations to the client-side escaping code
// are necessary, then the built-in client-side escaping can be disabled using
// `dontUnescapeOnClient: true`.
return unescapedValue;
}).toString() + '; ';
}
html += ' window.'+options.namespace+' = { ';

Expand Down

0 comments on commit 41d47ca

Please sign in to comment.