سؤال

I'm getting the following error generated from my default.html.eco layout when I attempt to render:

RangeError: Maximum call stack size exceeded

My docpad version is: v6.54.2, and the specific line causing it is this:

<%- @getBlock('scripts').add(['/vendor/foundation.min.js',
'/vendor/audiolib.js','/vendor/freqfinder.js','/vendor/modernizr.js']).toHTML() %>

If I remove this, I get a clean build.

Note that the styles block just above it renders just fine:

<%- @getBlock("styles").add(['/vendor/foundation.css']).toHTML() %>

So I decide to try truncating that list in the scripts block and it works:

<%- @getBlock("scripts").add(['/vendor/foundation.min.js']).toHTML() %>

Any ideas on how to work around this? I'll go file a bug if I'm not doing something wrong - new to docpad.

هل كانت مفيدة؟

المحلول

Do you have a line break in your code? It fails for me when I copy-paste from here to my layout file, but if I delete the line break between '/vendor/foundation.min.js', and '/vendor/audiolib.js' then it compiles as expected.

Alternatively, you could also a string of .add() commands like this:

<%- @getBlock('scripts').add('/vendor/foundation.min.js').add( '/vendor/audiolib.js').add('/vendor/freqfinder.js').add('/vendor/modernizr.js').toHTML() %>

That also comiples fine for me.

And a related note, in case anyone else comes across this error but doesn't have any line breaks: collection.add(null) now causes the same error message. So, if you're doing something like this:

<%- @getBlock("scripts").add( @getDocument().get('scripts') ).toHTML() %>

It will die if you don't have a scripts metadata field on every page.

The fix, however, is pretty simple:

<%- @getBlock("scripts").add( @getDocument().get('scripts') or [] ).toHTML() %>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top