GithubHelp home page GithubHelp logo

11ty-component-macro's Introduction

11ty-component-macro's People

Contributors

trys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

trevorsaint

11ty-component-macro's Issues

Not working with 11ty's layout system

Thanks for sharing this idea on your blog. It's the nicest components-in-eleventy solution I've come across.

After reading the blog post I ran off to try it but got hung up on a tricky issue. I'm writing it up here for anyone that follows.

Issue

I set up the component macro in a new project created with the eleventy base blog starter. My pages didn't have access to the component macro even though my top level layout (_includes/layouts/base.njk) imports it.

Error message is

Error: Unable to call `component`, which is undefined or falsey

I found that eleventy's layout inheritance doesn't work the same as in "vanilla" nunjucks. More details in 11ty/eleventy#212.

Workarounds

Do one of these

  • Use the extends and block tags of nunjucks instead of specifying a layout in the page's frontmatter. This is the workaround used by this repo.
  • Continue using eleventy's layout system and put {%- from "system/component.njk" import component -%} at the top of every page-level template that uses the component macro.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.