Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOM parser issue with HTML tags #1359

Closed
newkind opened this issue Jun 14, 2016 · 4 comments
Closed

DOM parser issue with HTML tags #1359

newkind opened this issue Jun 14, 2016 · 4 comments
Assignees
Milestone

Comments

@newkind
Copy link
Contributor

newkind commented Jun 14, 2016

There's a bug in DOM parsing cdata which causes such code :
html('<p>'+error+'</p>')
to throw errors like :

An exception has been thrown during the rendering of a template ("DOM Error 76: Unexpected end tag : p while parsing: <!doctype html> <html><head></head><body>...

because of that we need to use workarounds like :
html('<' + 'p>' + error + '<' + '/p>');

@mahagr
Copy link
Member

mahagr commented Jun 14, 2016

This issue was added to find a better way to add inline javascript without needing dom parser everywhere.

@w00fz
Copy link
Member

w00fz commented Jun 14, 2016

I think a good solution could be using the same token technique I implemented in 90654f1 for #1328

@mahagr
Copy link
Member

mahagr commented Jul 5, 2016

There are 4 new functions that can be used:

    {% do gantry.document.addStyle(url('gantry-assets://css/whoops.css'), 0) %}
    {% do gantry.document.addInlineStyle('a { color: red; }', 0) %}

    {% do gantry.document.addScript(url('https://cdnjs.cloudflare.com/ajax/libs/mootools/1.6.0/mootools-core.min.js'), 0, 'footer') %}
    {% do gantry.document.addInlineScript('alert("test");', 0, 'footer') %}
  • First parameter can also be array containing html attributes for the tag that will be used.
  • Second parameter is either 'head' or 'footer'
  • Third parameter is priority

@mahagr
Copy link
Member

mahagr commented Jul 6, 2016

Switched around the second and third parameter. Added also new docs for this.

@mahagr mahagr closed this as completed Jul 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants