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

liquidjs Regression on Relative Includes #1995

Closed
zachleat opened this issue Oct 3, 2021 · 4 comments · Fixed by #2071
Closed

liquidjs Regression on Relative Includes #1995

zachleat opened this issue Oct 3, 2021 · 4 comments · Fixed by #2071
Assignees
Labels
bug: dependency A problem in one of Eleventy’s dependencies high-priority release: beta A release on the beta channel

Comments

@zachleat
Copy link
Member

zachleat commented Oct 3, 2021

Related to harttle/liquidjs#395 (comment)

Locked to liquidjs 9.25.x starting in Beta 1.

cc @paulrobertlloyd

@zachleat
Copy link
Member Author

zachleat commented Nov 8, 2021

Shipping with 1.0.0-beta.5

@paulrobertlloyd
Copy link
Contributor

paulrobertlloyd commented Nov 9, 2021

Hmmm… not sure if this is a bug, or a change in the intended behaviour. I want to use setLiquidOptions so that I can add some globals:

eleventyConfig.setLiquidOptions({
  globals: {
    app: require('./src/data/app.js'),
    dates: require('./src/data/dates.js'),
    navigation: require('./src/data/navigation.js'),
    srcsets: require('./src/data/srcsets.js'),
  },
});



return {
  dir: {
    input: './src',
    output: 'www',
    includes: 'includes',
    layouts: 'layouts',
    data: 'data',
  },
  templateFormats: ['liquid', 'md'],
};

However I get the following error:

[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] > Having trouble writing template: www/bookmarks/2010/08/facebook_places/index.html

`TemplateWriterWriteError` was thrown
[11ty] > undefined is not iterable (cannot read property Symbol(Symbol.iterator)), file:./src/layouts/bookmark.liquid, line:1, col:1

`RenderError` was thrown
[11ty] > undefined is not iterable (cannot read property Symbol(Symbol.iterator))

`TypeError` was thrown:
[11ty]     TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
        at __values (/Users/paulrobertlloyd/Sites/paulrobertlloyd-v4/node_modules/liquidjs/dist/liquid.node.cjs.js:91:46)
        at Render.<anonymous> (/Users/paulrobertlloyd/Sites/paulrobertlloyd-v4/node_modules/liquidjs/dist/liquid.node.cjs.js:1101:35)
        at step (/Users/paulrobertlloyd/Sites/paulrobertlloyd-v4/node_modules/liquidjs/dist/liquid.node.cjs.js:84:23)
        at Object.next (/Users/paulrobertlloyd/Sites/paulrobertlloyd-v4/node_modules/liquidjs/dist/liquid.node.cjs.js:65:53)
        at reduce (/Users/paulrobertlloyd/Sites/paulrobertlloyd-v4/node_modules/liquidjs/dist/liquid.node.cjs.js:1021:25)
        at toThenable (/Users/paulrobertlloyd/Sites/paulrobertlloyd-v4/node_modules/liquidjs/dist/liquid.node.cjs.js:1016:16)
        at reduce (/Users/paulrobertlloyd/Sites/paulrobertlloyd-v4/node_modules/liquidjs/dist/liquid.node.cjs.js:1028:16)
        at Object.then (/Users/paulrobertlloyd/Sites/paulrobertlloyd-v4/node_modules/liquidjs/dist/liquid.node.cjs.js:989:43)
        at reduce (/Users/paulrobertlloyd/Sites/paulrobertlloyd-v4/node_modules/liquidjs/dist/liquid.node.cjs.js:1028:40)
        at Object.then (/Users/paulrobertlloyd/Sites/paulrobertlloyd-v4/node_modules/liquidjs/dist/liquid.node.cjs.js:989:43)

If I add layouts and partials to setLiquidOptions, my site builds fine:

eleventyConfig.setLiquidOptions({
  globals: {
    app: require('./src/data/app.js'),
    dates: require('./src/data/dates.js'),
    navigation: require('./src/data/navigation.js'),
    srcsets: require('./src/data/srcsets.js'),
  },
  layouts: './src/layouts',
  partials: './src/includes',
});

Does setLiquidOptions mean any values for the dir.includes and dir.layouts options get ignored? Is that the intended behaviour?

@zachleat
Copy link
Member Author

@paulrobertlloyd was this resolved with the 1.0 stable release? Seems to work okay for me with this config file:

module.exports = function(eleventyConfig) {
  eleventyConfig.setLiquidOptions({
    globals: {
      app: { hi: 123 },
      dates: {},
      navigation: {},
      srcsets: {},
    },
  });

  return {
    dir: {
      input: '.',
      output: 'www',
      includes: 'includes',
      layouts: 'layouts',
      data: 'data',
    },
    templateFormats: ['liquid', 'md'],
  };
};

@paulrobertlloyd
Copy link
Contributor

paulrobertlloyd commented Feb 18, 2022

Afraid not. With the following config:

module.exports = function (eleventy) {
  eleventy.setLiquidOptions({
    cache: true,
    globals: {
      app: require('./src/data/app.js'),
      dates: require('./src/data/dates.js'),
      navigation: require('./src/data/navigation.js'),
    },
  });

  return {
    dir: {
      input: 'src',
      output: 'www',
      includes: 'includes',
      layouts: 'layouts',
      data: 'data',
    },
    templateFormats: ['liquid', 'md', '11ty.js'],
  };
};

I get the following error:

[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] 1. Having trouble writing template: "www/notes/1493239140/index.html" (via EleventyTemplateError)
[11ty] 2. ENOENT: Failed to lookup "default" in "src/includes,src", file:./src/layouts/note.liquid, line:1, col:1 (via RenderError)
[11ty] 3. ENOENT: Failed to lookup "default" in "src/includes,src" (via Error)
[11ty] 
[11ty] Original error stack trace: Error: ENOENT: Failed to lookup "default" in "src/includes,src"
[11ty]     at Loader.lookupError (/Users/paulrobertlloyd/Sites/paulrobertlloyd-v4/node_modules/liquidjs/dist/liquid.node.cjs.js:974:19)
[11ty]     at Loader.<anonymous> (/Users/paulrobertlloyd/Sites/paulrobertlloyd-v4/node_modules/liquidjs/dist/liquid.node.cjs.js:887:37)
[11ty]     at step (/Users/paulrobertlloyd/Sites/paulrobertlloyd-v4/node_modules/liquidjs/dist/liquid.node.cjs.js:87:23)
[11ty]     at Object.next (/Users/paulrobertlloyd/Sites/paulrobertlloyd-v4/node_modules/liquidjs/dist/liquid.node.cjs.js:68:53)
[11ty]     at reduce (/Users/paulrobertlloyd/Sites/paulrobertlloyd-v4/node_modules/liquidjs/dist/liquid.node.cjs.js:1044:25)
[11ty] Copied 1504 files / Wrote 0 files in 4.54 seconds (v1.0.1-canary.3)

It seems to be looking for the default layout in the includes folder, thus ignoring the value given for dir.layouts.

Explicitly adding a value for layouts in setLiquidOptions fixes this issue:

eleventy.setLiquidOptions({
  cache: true,
  globals: {
    app: require('./src/data/app.js'),
    dates: require('./src/data/dates.js'),
    navigation: require('./src/data/navigation.js'),
  },
  layouts: './src/layouts',
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: dependency A problem in one of Eleventy’s dependencies high-priority release: beta A release on the beta channel
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants