[WIP] Template with {contentType ...} rendered to string should not modify global application state#106
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
9b37193 to
93b83ff
Compare
5792fb0 to
a3c72b8
Compare
|
Just note: |
03f0778 to
04cb696
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