Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # 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. :)

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

No branches or pull requests

1 participant