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

example needed: registerUndefinedTokenParserCallback() #3762

Open
therealpecus opened this issue Oct 17, 2022 · 0 comments
Open

example needed: registerUndefinedTokenParserCallback() #3762

therealpecus opened this issue Oct 17, 2022 · 0 comments

Comments

@therealpecus
Copy link

I am looking for a way to shim unknown tags from a loaded Twig file, while preserving internal nodes available to the parser/walker.

Are there code examples of how to use registerUndefinedTokenParserCallback()? It's rather trivial to shim with registerUndefinedFunctionCallback() and registerUndefinedFilterCallback(), but I have not found a way to skip unknown tags.

This code works for functions and filters, i.e. $env->registerUndefinedFunctionCallback(shimTwig(TwigFunction::class))

    function shimTwig(string $type) {
        return function ($name) use ($type) {
            return new $type($name);
        };
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant