Using Template Render twice, issue with previously submitted headers

24 views
Skip to first unread message

Summer White

unread,
Apr 21, 2017, 1:44:02 AM4/21/17
to Fat-Free Framework
I'd like to render a template into a variable to use later but when I do this it submits the headers.

Is there a standard way to prevent sending headers?

Summer White

unread,
Apr 21, 2017, 1:51:42 AM4/21/17
to Fat-Free Framework
It could also just be a bug.

$html = Template::instance()->render("/example.html", "text/plain"); // This mimetype is clearly being sent

echo
Template::instance()->render("/example.css", "text/css"); // whereas this one is not.

// Response header as seen from response header in firefox
// Content-Type: text/plain; charset=UTF-8

bcosca

unread,
Apr 21, 2017, 2:55:32 AM4/21/17
to Fat-Free Framework
Issue a Content-Type header before rendering so the template engine(s) do not issue a dupe.

ikkez

unread,
Apr 21, 2017, 3:04:50 AM4/21/17
to Fat-Free Framework
or just set the mime type to NULL

Summer White

unread,
Apr 21, 2017, 5:12:47 AM4/21/17
to Fat-Free Framework
Is the mime type not already set to null though as a default. Even though it was set to null it was still throwing a "text/html" mimetype header.

And issuing a header early is making to large an assumption at this point.

If I really have to I'd rather just read the file in and parse it myself but I'd rather not do that since I'd have to implement a lot of what Render does itself such as caching, handling UI directories, etc..

Summer White

unread,
Apr 21, 2017, 5:29:38 AM4/21/17
to f3-fra...@googlegroups.com
Confirmed.

$html = Template::instance()->render("index.html", null);
echo Template::instance()->render("test.css", "text/css");

This results in a text/html being sent. I'm calling this a bug and making a github issue.

Also, I could try creating a new Template instance but because Template derives from a Prefab which is a singleton this is not possible.

Singleton classes cannot and should not be instantiated through __construct. As such, __construct must be private.
Reply all
Reply to author
Forward
0 new messages