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

[Content]: Note Content-Type inference for template extensions #614

Open
AugustMiller opened this issue May 31, 2024 · 0 comments
Open

[Content]: Note Content-Type inference for template extensions #614

AugustMiller opened this issue May 31, 2024 · 0 comments

Comments

@AugustMiller
Copy link
Contributor

Product

Craft CMS

Description

When you create a template file like my-ajax-handler.json.twig, Craft will automatically send a Content-Type: application/json header. No need for {% header ... %} tags in the template—just echo out the JSON!

This should work for any MIME type detectable via craft\helpers\FileHelper::getMimeTypeByExtension($template)—but please don't try and "render" an MP3 in Twig. :)

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