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

Using include as a function results in "include function does not exist and is not defined in the context" error #23

Open
paulgoodfield opened this issue Mar 1, 2021 · 0 comments

Comments

@paulgoodfield
Copy link

There are certain times where I want to return the output of a rendered template as a string, which I can then set as the value of a variable.

E.g. Rather than have {% include "path/to/partial" with {foo: 'bar'} only %} I would want to have {% set myVar = include("path/to/partial", {foo: "bar"}, false) %}

Although I've used this without problems on other websites using Twig (e.g. Craft CMS), it doesn't look like this functionality is available with this package? When I try to use include as a function, I get the following error in my terminal:

TwigException: include function does not exist and is not defined in the context

I'm assuming there is a way around this by adding Twig.exports.extendFunction('include', ...) to the grunt config for the task, but I'm having trouble working this out. Any help would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant