DrupalCon Prague 2013

El pasado y el futuro de los temas de Drupal

Carl Wiedemann  · 



Código de la presentación

Puedes acceder al código fuente utilizado en esta presentación en el siguiente enlace:



Extracto de la transcripción automática del vídeo realizada por YouTube.

okay welcome drupalcon prague day too good stuff this is core conversation about the history and future of drupal theming hopefully you were you enjoyed the session description i hope this is as entertaining as the session description is this is based on a

session i gave at a drupalcamp a few months ago that was more about the history and it was more a narrative of how we got to where we are in the theme system and it didn't have a lot of like forward-looking what's next stuff this contains less history

and more forward-looking stuff because it is a core conversation now hopefully we'll have plenty of time to have like what about this what about that this is I will say this too it is it it's rated as an expert level session so it assumes you know

a lot about the theme layer in terms of the architecture and how it works and it's also not much about like HTML but more about like the underlying systems of like the theme registry and things like that so if you feel comfortable with that stuff and you

feel comfortable a little bit with object-oriented code then you're in the right place because we're going to kind of talk about those kinds of things we're also going to talk about render API and if that seems boring or intimidating and you'd

get bored you can leave and that's I won't be offended I understand because it is a very hard subject so my name is Carl wiedemann im sue for RL on drupal.org and i have worked some on the twig initiative especially at the beginning and i've been

working more on well I haven't been quiet lately but I'm more interested in kind of a future of render API and this is actually going to talk a lot about render API going forward so my goals today are to talk about where we've been where are we

going and then have discussion and planning and see like who might be interested in this or questions you might have about the future here so I'm going to go kind of a year-by-year and discuss what has kind of happened what did we get in Drupal over the

years if you go back in the commit history you can look in the get history all the way back to the year 2000 which is kind of fascinating about get and just the get migration and you can see some of those first commit messages and we actually did have a theme

system in the very first incarnation of rupal and the idea that existed from the start was having an override abul system and so throughout the years i'm going to talk about kind of ideas that we've come across and that we want to preserve because

not all our ideas are bad some of our implementations are bad but not all of the ideas are bad so we had over rideable markup in 2001 we were able to provide default markup that is you would only have to override certain things and that other things would

be provided by default for example the node module provides more default node markup so that was that was something that didn't exist in two thousand is a theme had to describe every single thing that possibly could be rendered on a site in 2002 we actually

finally had the theme function as kind of an API to get into okay how do I actually create markup how do I pull things out on my own and in 2003 everything before then was concatenated together and we still have some concatenation at existing core which is

not that easy to use especially if you're a newcomer because you don't want to dig through PHP files so we first had template-based name back in 2003 it was a system called ex template has anyone used ex template before Wow oh well he doesn't count

the ex template is not very powerful and so in 2005 PHP template came along and this is a lot of other things came along too and in 2005 but this was kind of our first modern theming system is we had Timbits that have logic in them we could override the variables

that were sent to those templates that's what it's called preprocessor functions now people familiar with preprocessor functions good and then a form API which wasn't related seeming yet arrived and altering arrives in constant the idea of a form

altar and providing an API for people to abstract structure and that eventually became very important in a few sure in 2007 we finally had a theme registry it was a lot more performant in terms of keeping track of the templates that were being overridden the

functions that were being overridden we had pre-processed functions in name that's when they were finally called pre-processed functions and we had template file overrides you could you could describe those yourself also in 2007 this has to do with with

kind of the form API world is we finally had hook elements and and the idea of structured versus rendered data which brought together the idea of the modern render API and so this is this is what we saw in Drupal 7 and before this we didn't really have

render API we're just kind of concatenated strings together how many people were Drupal 6 developers yeah so you just had strings you just mash them all together and it was kind of a pain and so this started the phase called alter all of the things which

is where you had the page array and hook node view and things of that nature where we wanted to abstract structure and the way that we do that in Drupal like we do everything else in Drupal is we just build up this big associative array and hope that people

are going to dig through that whole big thing and that seems like an okay dia to start with it's kind of like when the only tool you have is a hammer everything looks like a nail so when the only tool you have is an associative array everything you build

is an associative array and so there's this this is the kind of the famous comment back in in 2007 about how we should read returning structured data and so this is this is the big shift that happens and if you're a Drupal 6 developer a Drupal 5 developer

you remember this and then in Drupal 7 we were supposed to do this but there was actually a lot of this living in Drupal 7 unfortunately and so by this time we had a hook page alter we had preprocessor functions we had global preprocessors we could override

templates we could override the preprocessors themselves we could override theme functions we could actually change the theme registry so we could register different templates or functions in there and this was by 2009 we just have this big stack of api's

and they were all brought in for good reasons but by different people and with different intentions it was very inconsistent was very difficult to learn and around this time is when you've probably seen this picture and maybe you've seen this version

too but this is John Albin Wilkins basically describing what the theme architecture had become and that I think what's important to realize about Drupal dribble steam system and maybe Drupal itself and maybe even just kind of a lot of open source projects

is we have systems that no one sits down in designs and one sat down with this and drew it up and said this is what we're going to use this came about over years and years and years and there are things that we have their ideas that are part of the theme

system that have been there for a long time and it's not the ideas that that are bad it is the implementation of those ideas yeah put that put that on your know remember that so I think you know we reached a time in a round drupalcon Denver there was a

core conversation about how screwed up to me was that I think is what where we first saw this graphic and for the it was this time where we said we really have a really hard system it's so brittle what have we started over and so I think this was this

brought about this idea based on what we've built what do we need and and I'm kind of going to distill this into three things that I think we need we can talk about this this is a core conversation if people have other ideas I think we need kind of

three basic things we need template-based markup that can be extended and overridden that's pretty basic the things that we invented to give us that were things like hook theme preprocessors theme book suggestions theme registry twig what used to be PHP

template all of this is for the idea of overriding and having templates for marquette we need an abstract adult herbal structure and this is what came out of that comment by Barry Jasmine in 2007 and so this was what gave us render arrays what Greivis hook

node view hook page alter things like that where we have there's a renderable thing we can pass around when you create a block you return this abstract in structure and I think the third thing we need is a sensible accessible API and this is really the

big missing part and we have some kind of things that have tried to give us this i mean the theme function drupal render render hide and show have kind of been tools in order to deal with a lot of the underlying architecture but i think the underlying architecture

is really the big problem and as nice as as twig looks there are certain things that we just cannot do easily because of that underlying architecture and so we had a core conversation in Denver the twig initiative was started we had one of the biggest sprints

in Portland I've ever seen for twig there's a cute you know the enthusiasm about twig is awesome but there's still a lot to be done we've done we've done some great things we've killed the the process layer that was part of the theme

system we're cleaning up mark up a lot of people are excited about twig and it's a good thing so all that's kind of where we went there's some current issues I want to talk about that's kind of where we're going and then I want to talk

about far kind of looking ahead and I hope that is interesting to folks so these are some kind of current issues there on my mind kind of i think in increasing importance to me personally there's probably some other ones that maybe you guys have seen and

i'll just i'm going to jump to do to talk about these things so the famous node 1 757 550 one of my favorites this was the big o let me go to that node here we are convert the core theme functions to twig templates so this is still active a lot of

this was the basis for the sprint and the entire twig initiative a lot of this is done there are a few things left and we have a great momentum on here Scott Reeves Fabian axe Jim Lampton true joelle all those all those folks have done awesome work here and

I've worked on this quite a bit too so this is just finishing up when I say kill concatenation I mean we want everything to be in twig and twig is a Tibble based system so no more concatenated my yup we want that to go away and hopefully we can make it

performant enough so that it can go away question so you're sure so in the question was can an example of concatenated marquette let me actually actually that would have to be d7 well I just need to open the code base so in themed Inc like theme table

[ ... ]

Nota: se han omitido las otras 5.504 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.