11ty / eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.
https://www.11ty.dev/
MIT License
17.28k stars 495 forks source link

"AssertionError: illegal input" when specifying templateEngineOverride and permalink() in .11ty.js template #943

Open pdehaan opened 4 years ago

pdehaan commented 4 years ago

Describe the bug I'm seeing the following error when I try and set both the templateEngineOverride and a permalink() function in the data() method of an *.11ty.js template:

$ npx eleventy

Problem writing Eleventy templates: (more in DEBUG output)
> Having trouble rendering md template ./src/posts/post-8.11ty.js

`TemplateContentRenderError` was thrown
> Having trouble compiling template ./src/posts/post-8.11ty.js

`TemplateContentCompileError` was thrown
> illegal input

`AssertionError` was thrown:
    AssertionError: illegal input
        at assert (/Volumes/Dev/github/pdehaan/11ty-setQuietMode-test/node_modules/liquidjs/dist/liquid.common.js:1062:11)
        at parse (/Volumes/Dev/github/pdehaan/11ty-setQuietMode-test/node_modules/liquidjs/dist/liquid.common.js:1426:3)
        at Object.parse$$1 [as parse] (/Volumes/Dev/github/pdehaan/11ty-setQuietMode-test/node_modules/liquidjs/dist/liquid.common.js:3419:18)
        at Liquid.compile (/Volumes/Dev/github/pdehaan/11ty-setQuietMode-test/node_modules/@11ty/eleventy/src/Engines/Liquid.js:181:29)
        at Markdown.compile (/Volumes/Dev/github/pdehaan/11ty-setQuietMode-test/node_modules/@11ty/eleventy/src/Engines/Markdown.js:63:25)
        at TemplateRender.getCompiledTemplate (/Volumes/Dev/github/pdehaan/11ty-setQuietMode-test/node_modules/@11ty/eleventy/src/TemplateRender.js:192:26)
        at Template.compile (/Volumes/Dev/github/pdehaan/11ty-setQuietMode-test/node_modules/@11ty/eleventy/src/TemplateContent.js:167:42)
        at async Template.render (/Volumes/Dev/github/pdehaan/11ty-setQuietMode-test/node_modules/@11ty/eleventy/src/TemplateContent.js:181:16)
        at async Template._getLink (/Volumes/Dev/github/pdehaan/11ty-setQuietMode-test/node_modules/@11ty/eleventy/src/Template.js:103:26)
        at async Template.getOutputHref (/Volumes/Dev/github/pdehaan/11ty-setQuietMode-test/node_modules/@11ty/eleventy/src/Template.js:138:16)
Wrote 0 files in 0.16 seconds (v0.10.0)

To Reproduce Steps to reproduce the behavior:

// src/pages/post-8.11ty.js
class Test {
  data() {
    return {
      name: "markdown",
      templateEngineOverride: "11ty.js,md",
      permalink: data => "/aboot/youu/"
    };
  }

  render(data) {
    return `# This is ${data.name}`;
  }
}

module.exports = Test;

What's interesting is, the code seems to work if I omit either templateEngineOverride value or permalink() method, but fails when I use them both. Also interesting is that if I use the static value for a permalink, it seems to work:

permalink: "/about/you/"

Expected behavior A clear and concise description of what you expected to happen.

Environment:

Additional context Add any other context about the problem here.

reubenlillie commented 4 years ago

Related to #642?