1

I have a setup where I'm using a component library that I have as an npm package. To use these components I need to extend templates that live outside of the /templates directory. So I need to achieve something like:

{% extends "../../../../node_modules/design-system/page-templates/_template.njk" %}

I will be extended from within a template that is located from within the /templates directory but allows for extends from outside of it.

Any help would be great.

1

You need to define and register your template roots for this folder:

Event::on(
    View::class,
    View::EVENT_REGISTER_SITE_TEMPLATE_ROOTS,
    function(RegisterTemplateRootsEvent $e) {{
        $e->roots['my-fancy-prefix'] = 'someDir';
    }
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.