-
-
Notifications
You must be signed in to change notification settings - Fork 112
[WIP] Template with {contentType ...} rendered to string should not modify global application state #106
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
Conversation
0f5ab19 to
347438c
Compare
|
Sounds logical. Imho sending of the header should be removed altogether, as "sending a headers from templating engine" sounds very wrong when you say it out loud like this. Sadly, that would be a giant BC Break. |
|
I think it is great that latte file knows it's content type. That's why latte is what it is - content escaping. render() should behave the same as it behaves now. Method is dependent on script output anyway so I think it should send headers. Headers needs to be sent before output and it will be really tricky to implement without sending it directly from template because you know content type only at runtime. (e.g. (btw. this kind of type dynamic makes static analysis impossible) @JanTvrdik renderToString(): It should just return string with output as it does now. There can introduced something like |
347438c to
ac05e6b
Compare
|
Alternate solution can be to declare content type in static way. e.g. using template headers (something very similar to file-level docblock) Then:
|
I agree, I just think the macro shouldn't be sending HTTP Headers. In Lavito, we've implemented "the symfony way" of naming templates (while integrating latte into symfony)... that means
I disagree. We could make it that you have to set the type from control/presenter (some template object setter - compiler has that ability already) and deprecate the macro - which would solve the chicken egg problem of fetching the content type, sending the header and rendering the template. The real BC Break would be only those few templates where you have I agree the |
I do not agree with this. I has two downsites:
Template for itself must know what is inside. I think there are two meaningfull ways of doing that:
|
9201aa6 to
1bb5b1a
Compare
0866aa4 to
959c81c
Compare
5792fb0 to
a3c72b8
Compare
|
Just note: |
34fd4ef to
25ccd58
Compare
81e91cf to
d3f86a5
Compare
Anything rendered to string should not modify global application state. Unfortunately it is not a case with macro
{contentType mime-type}which sets headers directly. ref to latte codeExpected behaviour would be to:
render()method modifies application output directly, it is expected to modify output headersrenderToString()should NOT modify headers - there should be some other API to get headers set by template