Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
request processing system
Priority:
Normal
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
6 Sep 2014 at 13:18 UTC
Updated:
11 Mar 2016 at 15:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dawehnerI am aware that this will conflict with #2256365: Factor render->fragment code out to a service though I would like to throw it out in order to get an issue created so that
it is more clear what needs to be done.
Comment #2
Crell commentedThanks, dawehner!
These need to be turned into add*() methods, like addLinkElement() and addMetaElement(). There's no reason for style and script tags to be handled differently at this level than any other header. That means they come out of the constructor, too.
Comment #3
Crell commentedComment #4
fabianx commentedI do think JS and CSS belong there, maybe even html_head, but adding library, will be a problem as there can be arbitrary things in attached now at this moment, see drupal_process_attached(), and this should parse the libraries down to CSS / JS.
As that is all that e.g. an ESIFragmentRenderer should care about.
Comment #5
Crell commentedThere's nothing special about CSS and JS as far as *adding* them. Honestly I don't even think $cache belongs in the constructor here. This is a setter-filled object. Use 'em.
Comment #6
fabianx commentedI agree they probably don't belong in the constructor, however given how browsers work, and if I understand the plan correctly that you want to e.g. use a ESIHtmlFragment, what you want to do is:
- Special case CSS, you need to e.g. queue them via JS if retrieving a ESI fragment as it can no longer change the original assets. You then want to get them in aggregated form of what CSS is not yet present on the page.
- Special case JS, you need to queue them for a ESI case, but for a Big Pipe workflow case you probably want to just put them in the original JS, but output in the footer. You want to possible combine them with the existing aggregates.
- Process all other #attached things and convert to JS / CSS.
Another special case is html_head, which just is queued via JS and then attached to the element, I cannot see currently why an ESIFragment would like to change the HTML head though.
Also cache is a very important information for an HTMlFragment, not only the #cache tags, but also the 'header' or a TTL of the content and usually also the global cache granularity (per page, per role, per user). I know we now have generally cache contexts, but the granularity is still important for determining if an ESI Fragment could be cached, especially if talking of recursive caching.
Just my thoughts, FWIW, I am prototyping some things of this in contrib.
Comment #7
dawehnerTrue,
Comment #8
dawehnermuh.
Comment #13
dawehnerLet's work on make it actually render something.
Comment #15
Crell commentedThat syntax is lovely, but only works on PHP 5.5. :-(
CSS and JS should be modelled with a StyleElement and ScriptElement, like Link and Meta. Those two in particular also allow for bodies.
Mutating the array form of a render array's asset definitions to the object form should be RenderHtmlRenderer's job. (As soon as that finally lands...)
Comment #16
dawehnerWow, I taught crell something about PHP: http://3v4l.org/Vjnst
Comment #17
Crell commentedWha? I thought that was added in 5.5. Carry on then! (But then I don't know what the fatal is about.)
Comment #18
dawehnerWe talked in IRC and we are kind of sure that we should not reference Script and Style elements but rather domain objects for CSS/JS/Libraries.
Sadly I doubt that these domain objects are solveable easily, unless we have #1762204: Introduce Assetic compatibility layer for core's internal handling of assets going in.
This just tracks work, no big progress.
Comment #19
andypostlooks outdated
Comment #20
dawehnerTotally