ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Curly braces getting removed from javascript template files

July 08, 2011 2:13am

Subscribe [5]
  • #1 / Jul 08, 2011 2:13am

    Dave @ Exp:resso

    465 posts

    Upgraded to EE 2.2.1, now bits of javascript are going missing. Case in point

    $("#sidebar_events").tabs("#sidebar_events div.pane", {tabs: 'h2', effect: 'slide', initialIndex: null});

    now looks like this when output

    $("#sidebar_events").tabs("#sidebar_events div.pane", );

    Obviously EE is getting a bit excited and interpreting it as a bit of template code. EE shouldn’t really be parsing javascript files at all surely?

  • #2 / Jul 08, 2011 3:43am

    narration

    773 posts

    CrescendoNZ, here’s the latest bug report on this and related issues—there have been others.

    Ellis brought out some patches mentioned there which you can apply to 2.2.1, which will help. We’re having a conversation there to bring out and get resolved all the issues.

    In the mean time, with or without the patch, you can get back your Javascript operating properly by avoiding $config[‘debug’] = “0”;

    As the CP isn’t accurately rendering or controlling for all states of this, the safe way to get this for now is to set $config[‘debug’] = “1”; in your system/expressionengine/config/config.php file.

    Can’t believe your report was the first thing to show here, just checking the forum after I’d added to that bug report this evening 😉.

    Regards, and hope that gets you going,
    Clive

  • #3 / Jul 08, 2011 4:12am

    Dave @ Exp:resso

    465 posts

    Interesting, that is certainly a comprehensive bug report and I don’t have time to start reading the EE code right now (though I usually do that and am fairly familiar with it).

    For the record, I do have the new patch applied (don’t get me started on patches without version numbers to reference them by), but just checking config.php I do have $config[‘debug’] = “0”, and have never changed that (not going to now, I’d rather just fix my javascript to work around it).

    But it seems bloody weird that anything to do with debugging on/off should affect whether the EE template engine eats javascript. I don’t think it should be parsing JS files at all.

    I just wish EllisLab had some actual unit test coverage of their code base so that entire sites wouldn’t come crashing to a halt every time we get a new version release.

    Cheers for the tip though!

  • #4 / Jul 08, 2011 6:47am

    narration

    773 posts

    Yes, I understand. And there are much clearer reports on the central problem; it’s just that there became more that turned up, which needs fixing for other reasons.

    The tip I think is quite simple and safe: use config debug 1, set in the config.php, to get your JS-JSON back.

    To explain, the reason JavaScript is affected by debug settings is that Ellis has for a long time allowed config-debug of 0 to clean up any apparent errors whatsoever, so that an end-customer in a commercial situation would not see them. This from long ago would have included unparsed EE variables, which as you know are formed as {variable}.

    The problems have arisen because JavaScript blocks and JSON are now in considerable use, to include Ellis’s own SafeCracker, and they can look enough like what EE currently removes to get the same treatment.

    I think I’ve realized the reticence to deal with this has been grounded in concern to not upset legacy and perhaps highly visible sites which may depend on debug 0 to look clean.

    That’s why I’ve proposed finally that they actually parse and properly treat both cases, unmatched variables and script-tagged areas, so that JavaScript-JSON remains unaffected while keeping the rest of the legacy behaviour.

    Meanwhile, use the 1, Luke, I think…

    Regards,
    Clive

  • #5 / Jul 08, 2011 1:38pm

    Kyle Cotter

    730 posts

    Hi CrescendoNZ,

    As of ExpressionEngine Version 2.2.0, the

    $config[‘debug’] = “0”

    option has been removed. Can you try as narration said and change that to “1” and let us know if that fixes it?

    For a more complete list of updates made to the system, please visit the changelog.

    Thanks.

    And thanks narration for the help here!

  • #6 / Jul 08, 2011 7:43pm

    Dave @ Exp:resso

    465 posts

    Great thanks guys.

    As I said, I ended up just fixing the javascript, since on my site at least it was only a few lines. But I can imagine on larger sites it would be more of a pain!

    I’ll rest easy knowing that it’s being dealt with by the higher powers.

    Kyle, I don’t understand what you mean when you say the option has been removed though. It very much seems to be there to me.

    Cheers
    Adrian

  • #7 / Jul 09, 2011 1:37am

    Justin Long

    196 posts

    That would be the case if you updated your site from a previous version of EE since the config.php file is replaced with your old config file that you backed up when you do an update. New installs have indeed removed

    $config['debug'] = "0"

    and as of EE2.2.0 you are no longer able to select it as an option from the control panel.

  • #8 / Jul 11, 2011 5:39pm

    Brandon Jones

    5500 posts

    Yep, thanks Justin.

    Sounds like everyone here is good to go, and we’re working on clarifying this in future releases. Thanks all!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases