From 57403a83fda0d0a35f2719fa5bd5875f81c12d99 Mon Sep 17 00:00:00 2001 From: maximebf Date: Mon, 24 Mar 2014 10:34:20 -0400 Subject: [PATCH] avoid triggering error if hljs is not loaded (fixed #107) --- src/DebugBar/Resources/widgets.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/DebugBar/Resources/widgets.js b/src/DebugBar/Resources/widgets.js index 1369465..6589a68 100644 --- a/src/DebugBar/Resources/widgets.js +++ b/src/DebugBar/Resources/widgets.js @@ -47,14 +47,20 @@ if (typeof(PhpDebugBar) == 'undefined') { * @return {String} */ var highlight = PhpDebugBar.Widgets.highlight = function(code, lang) { - if (typeof(code) == 'string') { + if (typeof(code) === 'string') { + if (!hljs) { + return htmlize(code); + } if (lang) { return hljs.highlight(lang, code).value; } return hljs.highlightAuto(code).value; } - code.each(function(i, e) { hljs.highlightBlock(e); }); + if (hljs) { + code.each(function(i, e) { hljs.highlightBlock(e); }); + } + return code; }; /**