Widget template id Unexpected token -

Issue #11 resolved
Paweł Srebniak
created an issue


When I Install mezzanine-pagedown on my site i see errors like this:


Uncaught SyntaxError: Unexpected token -


SyntaxError: missing ; before statement

var converter_content-04a50d0e-8f36-4bf3-968a-32ac54cde0af = Markdown.getSanitiz

Comments (13)

  1. Ahmad Khayyat repo owner

    OK. I think I see the problem now. Firefox says:

    SyntaxError: missing ; before statement

    The line causing the error is:

    var converter_content-50cbfcc1-811d-42f0-bc19-5861c721e118 = Markdown.getSanitizingConverter();

    So it seems that the hyphens are causing an issue indeed. This is all happening in the frontend when in-line editing is enabled, which admittedly I never tested. No such issues in the website itself (without in-line editing) or in the admin site.

  2. Ahmad Khayyat repo owner

    Thanks Tuk!

    Now I get:

    Uncaught ReferenceError: Markdown is not defined

    which is the result of the <script> tags that are required for the editor (see widgets.py) appearing later in the page than the editing form.

    I managed to avoid these new errors by moving the inclusion of js files that are required for the editable form from the footer to the header of the page using this patch against Mezzanine:

    --- a/mezzanine/core/templates/base.html
    +++ b/mezzanine/core/templates/base.html
    @@ -35,6 +35,7 @@
     <script src="{% static "mezzanine/js/"|add:settings.JQUERY_FILENAME %}"></script>
     <script src="{% static "js/bootstrap.js" %}"></script>
     <script src="{% static "js/bootstrap-extras.js" %}"></script>
    +{% editable_loader %}
     {% block extra_js %}{% endblock %}
     {% endcompress %}
     <!--[if lt IE 9]>
    diff --git a/mezzanine/core/templates/includes/footer_scripts.html b/mezzanine/core/templates/includ
    --- a/mezzanine/core/templates/includes/footer_scripts.html
    +++ b/mezzanine/core/templates/includes/footer_scripts.html
    @@ -1,7 +1,5 @@
     {% load mezzanine_tags %}
    -{% editable_loader %}
     {% if settings.GOOGLE_ANALYTICS_ID and not request.user.is_staff %}
     var _gaq = _gaq || [['_trackPageview']];

    Unless there is a better way, or a way that does not require such changes in Mezzanine itself, this now needs to be discussed in the Mezzanine project.

    We also need to make sure that changing the IDs (replacing dashes with underscores) does not break anything.

  3. Paul Whipp

    This error stops the javascript processing so is pretty serious. The workaround looks good but when I tried installing Tuk's fix_dashes branch it is only at v0.5 and breaks on a missing template (mezzanine_pagedown/editor.html).

    Am I going to have to create a fork of the current version and merge in Tuk's fix dashes change to move forwards?

  4. Lee Hodgkinson

    This is marked as resolved, but on an install from pip pip install mezzanine-pagedown I reproduce exactly this error, is pip installing a version without the fix or something?

  5. Log in to comment