Open cfjedimaster opened 3 years ago
So this is interesting. I have beta8 installed globally. I also have it installed in my test folder. If I run eleventy, I get the error above. If I specifically use the local copy with npx eleventy, it runs fine. Both output the exact same version.
Hmmmmmmmmm.
Is that the full contents of the file?
We do have an automated test suite for these plugins that does run on Windows too https://github.com/11ty/eleventy/actions/runs/1472651558
Can you try where Eleventy is not in node_modules but installed globally?
Had to get my $NODE_PATH going again for global node_modules but I got the same successful result 😭
Sorry to do this but can you make a reduced test case repo that shows this locally for you?
I don’t think I’m seeing all the variables things at play here
Not a problem - will do so but may take a day.
Here there are no errors - instead the template render simply stops.
Upon npm run build
the template src/index.njk
{% extends "base.njk" %}
{% set content %}
<section id="book-title">
{% renderTemplate "md" %}
# Title of Book
by Author
{% endrenderTemplate %}
</section>
{% endset %}
results in the following markup dist/index.html
:
<!DOCTYPE html>
<html lang="en">
<body>
<div id="page">
<section id="book-title">
</div>
</body>
</html>
i.e the template fails to render past the point of the renderTemplate "md"
.
Platform:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal
$ node -v
v16.13.0
$ npm -v
8.1.0
$
FYI: https://github.com/11ty/eleventy/blob/master/src/TemplateRender.js#L29
console.log('\ninputDir', inputDir);
this.inputDir = inputDir ? inputDir : this.config.dir.input;
console.log('this.inputDir', this.inputDir);
this.includesDir = TemplatePath.join(
this.inputDir,
this.config.dir.includes
);
console.log('includesDir:', this.includesDir);
results in
$ npm run build
> 11ty-rendertemplate@1.0.0 build
> npx @11ty/eleventy
inputDir src
this.inputDir src
includesDir: src/_includes
inputDir src/_includes
this.inputDir src/_includes
includesDir: src/_includes/_includes
[11ty] Writing dist/index.html from ./src/index.njk
[11ty] Wrote 1 file in 0.08 seconds (v1.0.0-beta.8)
So that second TemplateRender
instance is provided with the includes path as the input path.
So to be clear, you see an error (template not rendering), but not the same issue in console as me? Also, do you see a difference between global eleventy
versus local?
Given I can get it to fail locally I never explored a global installation.
However I used your error message to zero in on the faulty includesDir
setting of that second TemplateRender
instance - which likely is responsible for the failure.
Too be clear I'm not familiar with the code that creates TemplateRender
- the first question that comes to my mind is why are two instances created when there is only one renderTemplate
render.
The difference between "build error" and "no build error" may simply be a manifestation of "liquid" vs "nunjucks" responding to the same root cause.
Awesome, thank you for a test case—lookin’
Couple of things came from this issue. We were absolutely passing in the wrong directory there to Template Render. That fix will go up with Beta.9
The other thing happening here is a Nunjucks specific issue with nested async shortcodes. Work in progress is happening here for that https://github.com/11ty/eleventy/pull/1749
This still doesn't sound exactly like my issue, but I'm going to wait and test again in 9. :)
Looks like I'll be using the following for a while
{# src/index.njk #}
{% extends "base.njk" %}
{% set content %}
<section id="book-title">
{% renderTemplateMd %}
# Title of Book
by Author
{% endrenderTemplateMd %}
</section>
{% endset %}
// .eleventy.js
//
const markdownIt = require('markdown-it');
const md = markdownIt({
html: true,
});
function renderMd(content, inline) {
return inline ? md.renderInline(content) : md.render(content);
}
const dir = {
input: 'src',
includes: '_includes',
output: 'dist',
};
module.exports = function(config) {
config.addPairedShortcode("renderTemplateMd", renderMd);
return {
dir
};
};
resulting in
<!DOCTYPE html>
<html lang="en">
<body>
<div id="page">
<section id="book-title">
<h1>Title of Book</h1>
<p>by Author</p>
</section>
</div>
</body>
</html>
For the record @peerreynders I believe your issue is separate @cfjedimaster’s original issue. I filed yours at #2108. Specifically note this comment: https://github.com/11ty/eleventy/issues/2108#issuecomment-974714754
My suspicion here @cfjedimaster is that this might be mixing and matching a global with a local installation?
Like, maybe you’re executing a global Eleventy but it’s requiring from a local Eleventy. And the versions are different?
What’s your NODE_PATH? Are there local installations of Eleventy at play?
Both the local Eleventy and global are the same version version. NODE_PATH is not defined.
FYI, I stumbled on the same issue as originally reported when using eleventy Github action while my local build works. I use v2.0.1 locally. The Github action is doing a global install of eleventy, but then also runs an npm install
, which will install a local eleventy. I use Nunjucks.
Describe the bug I'm trying this simple example of the renderTemplate feature (using beta8):
And when I run eleventy, I get:
To Reproduce See above. :)
Expected behavior I'd expect the block to render from Markdown.
Environment:
eleventy --version
ornpx @11ty/eleventy --version
] v1.0.0-beta.8