eleventy: renderTemplate fails with simple example (global versus local install)

Describe the bug I’m trying this simple example of the renderTemplate feature (using beta8):

{% assign name = "Ray" %}
Hello World, and {{ name }}

<p>

{% renderTemplate "md" %}
# I am a title

* I am a list
* I am a list
{% endrenderTemplate %}

And when I run eleventy, I get:

ray@Hoth:~/projects/testingzone/eleventybeta$ eleventy
[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] > Having trouble rendering liquid template ./index.liquid

`TemplateContentRenderError` was thrown
[11ty] > Cannot read property 'includes' of undefined, file:./index.liquid, line:8, col:1

`RenderError` was thrown
[11ty] > Cannot read property 'includes' of undefined

`TypeError` was thrown:
[11ty]     TypeError: Cannot read property 'includes' of undefined
        at new TemplateRender (/home/ray/projects/testingzone/eleventybeta/node_modules/@11ty/eleventy/src/TemplateRender.js:31:23)
        at Object.render (/home/ray/projects/testingzone/eleventybeta/node_modules/@11ty/eleventy/src/Plugins/RenderPlugin.js:31:12)
        at Object.renderStringShortcodeFn (/home/ray/projects/testingzone/eleventybeta/node_modules/@11ty/eleventy/src/Plugins/RenderPlugin.js:224:27)
        at Object.render (/home/ray/projects/testingzone/eleventybeta/node_modules/@11ty/eleventy/src/Plugins/RenderPlugin.js:116:40)
        at async Template._render (/home/ray/.nvm/versions/node/v14.18.0/lib/node_modules/@11ty/eleventy/src/TemplateContent.js:315:22)
        at async Template.getTemplateMapContent (/home/ray/.nvm/versions/node/v14.18.0/lib/node_modules/@11ty/eleventy/src/Template.js:1003:19)
        at async TemplateMap.populateContentDataInMap (/home/ray/.nvm/versions/node/v14.18.0/lib/node_modules/@11ty/eleventy/src/TemplateMap.js:459:39)
        at async TemplateMap.cache (/home/ray/.nvm/versions/node/v14.18.0/lib/node_modules/@11ty/eleventy/src/TemplateMap.js:360:5)
        at async TemplateWriter._createTemplateMap (/home/ray/.nvm/versions/node/v14.18.0/lib/node_modules/@11ty/eleventy/src/TemplateWriter.js:242:5)
        at async TemplateWriter.generateTemplates (/home/ray/.nvm/versions/node/v14.18.0/lib/node_modules/@11ty/eleventy/src/TemplateWriter.js:275:5)
[11ty] Wrote 0 files in 0.03 seconds (v1.0.0-beta.8)

To Reproduce See above. 😃

Expected behavior I’d expect the block to render from Markdown.

Environment:

  • OS and Version: [e.g. Windows/Mac/Linux] Windows/WSL
  • Eleventy Version [via eleventy --version or npx @11ty/eleventy --version] v1.0.0-beta.8

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 18 (8 by maintainers)

Commits related to this issue

Most upvoted comments

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

Reduced test case repo

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.