diff --git a/tmpl/examples.tmpl b/tmpl/examples.tmpl index 3c3518a9..2e77acd9 100644 --- a/tmpl/examples.tmpl +++ b/tmpl/examples.tmpl @@ -6,9 +6,6 @@ data.forEach(function(example) { - var jsonString = JSON.stringify(example.code) - .replace(/"/g, """) - .replace(/'/g, "'"); if (example.caption) { ?>

@@ -20,13 +17,23 @@ if(enable_for.findIndex(function (val) { return val === "examples"}) !== -1) { var options = codepen.options || {}; var optionsString = ''; - var optionsKey = Object.keys(options) + + var code = `${options.js} +${example.code} + ` + + var jsonString = JSON.stringify(code) + .replace(/"/g, """) + .replace(/'/g, "'"); + + var optionsKey = Object.keys(options).filter((key) => key !== 'js' ) optionsKey.map((key, idx) => { optionsString += '"' + key +'": "' + options[key].replace(/"/g, """).replace(/'/g, "'") + '"'; if(idx !== optionsKey.length - 1) { optionsString += ',' } }) + ?>
", "js": , }' />