Transcripción
Extracto de la transcripción automática del vídeo realizada por YouTube.
all right hello there's a few more people still shuffling in what let's get this show started if you love PHP template I have bad news we're here to talk about twig but not only twig also the other changes throughout the theme layer for Drupal
8 to make things better for front enters everywhere so we'll just start with the introduction my name is scott orkut sir i'm a just a developer drupal developer at digital echidna just quick shout out to them for sponsoring me to come here which is
great and fabian you want to introduce yourself yeah I'm Fabian France or Fay beings on drupal.org it's one crazy day I had this idea of that district there was this little problem to soften it was like it wasn't that hard and suddenly I was together
with Jen leading this initiative but we had success and it's very nice so I'm currently a tech one consulting loving it and yeah hope you have fun with the session hi I'm Joelle potete and I jumped onto this twig project just to help out and I
got sucked in and it's been good so far because it feels a lot better than the PHP template that I used to use and I'm Jen Lampton I'm also independent I'm working on the twig project for the last year and a half um really hoping it gets everything
everyone wants out of it done so and a pony alright so now that you know who we are why are you here and what is this talk about we want to talk about the pain and what we have done and what we are going to do to try and take that away from and so to give
you a better theming experience so we're going to talk about syntax inconsistency complexity redundancy and security and so this is just an overview so we'll talk about each of these I think Jen do you want to talk about syntax sure so there are a
couple of problems with the syntax in in Drupal 7 for starters that when you are printing variables in your template files there are lots of different ways to identify your variables if you're printing an object you print things out with an arrow if you're
printing something in an array you bring them out with square brackets sometimes you just print things and for people who are experts in HTML and CSS they shouldn't need to know the difference between an object or an array or how to access bits and pieces
of them and more importantly a nation need to know which things Drupal decided to make which other things and it's kind of would be nice if we could print everything the same way and let the people who are experts in the template files do what they do
best and leave the yucky stuff to the developers so in twig and we've eliminated the need to print things differently it doesn't matter whether it's an object or an array or a plain variable if you want to print it you just print it so um gets
a lot better yeah there's also different ways we print things in Drupal 7 sometimes you just print them to the page and sometimes you have to print render them not only is print rendering things a little bit redundant but it's another one of these
things where we're leaving it to the front end community to understand when Drupal requires that you rent or something and when you can just print it where we really should just be able to print everything the same way so in twig we've made it so that
you don't have to render your renderable so you can print them exactly like you print everything else into it will handle the rendering for you just print it yes print it and inconsistency is another pain point so many different ways of doing the same
thing sometimes we use template files sometimes we use theme functions theme functions are always a pain to override and when I was learning theming Drupal I thought that it was crazy that you have to take this whole function and copy it into your theme and
then just change these little bits and it also means that you need to know PHP basically to change that markup so in Drupal 8 with an asterisk only template files are provided in Drupal 8 we're probably going to drill this into your head by the end of
this but we need your help to make all this a reality so if you're still in town on Friday please come to the sprint no matter your skill level and experience you can help trust me if you have built a site in Drupal you can help us out and help yourself
out at the same time so and also the just the sheer amount of template files and themed functions e we can't even show you them all and you can't read any of these there's a lot of them and it's it's just sort of it's too much it's
too many layers it's too complex so we are trying to get rid of them consolidate them if they're the same thing let's just use the same template but we need your help and I'll pass this on this is talking about render A's and theme functions
let's take that I can take that and so in general we had a very big inconsistency there in general most functions in coop would already kind of deuces that they create this big arrays with a built and then you would kind of have this as an render array
but there were also lots of places in core where you would actually call the same function and we are actually very close to duplicating that from Drupal a Drupal 8 which means that overall what we can now do is we can do lots of things within the rendering
system that if before I hadn't been possible because we now have one consistent way to call it so if in your modules you are still kind of using theme codes start converting them now that will also help with performance caching and other things trust me
it's versity so it's basically it's taking its it's taking the call to the theme function and convert that to a render way with hash theme equals and so it's it's usually a fairly straightforward conversion to this new way and like
Fabian was saying there's so many benefits and complexities another pain point this is this is one of my favorite slides because it looks it looks so evil look at it so this is pretty much what Drupal 7 looks like John Albin Wilkins who is the one of the
theme system maintainers and was for Drupal 7 as well sort of figured it all out and created this diagram and I sort of like to refer to this as the monster that we created so we're trying not to do that this time we're trying to sort of think through
and think about the use cases and what people actually need so in this little story to that when we finally at the last Rubicon after five days of extensive sprinting got trick at least secured almost in court the mega patch was ready it just had to be kind
of applied and it was applied the next day and I was flying back Jenna me they said sitting last in the coding knowledge and reality check debating those things anymore and then we kindly found well we've just designed a new sim system in five easy steps
read it yes so yes I'm glad that you told that story feeling because that's very important to this a lot of a lot of twig happened after hours and just putting in the extra effort to make this happen and make this a reality for everyone and that's
that's a perfect example so it's sort of it's it's adding a few things but it's also taking away and simplifying so we'll talk more about this later but it's just it's not jamming most of this is just not jamming so much things
in pre process that don't really belong there so I mean we'll talk more about that later and we do still need your help yeah and if you now form API you will kind of love it because it's very similar yeah it is very much like form API and redundancy
and we ask in Portland actually and people were like hey I get it that's nice so we got positive feedback and so we continued with initiative yeah it's something it's something that's familiar to a lot of developers already so the structure
so redundancy this is a huge win that we get with twig if you're creating no templates for example you have knowed article you have knowed page and you can get more specific than that of course in in Drupal 7 you would be forced to basically well the standard
way anyway would be basically to copy your node template but then you have to maintain 4 or 10 or 20 sets of the same markup just to change one part twig actually gives us real template inheritance so you can say on the right side here where it says extends
node HTML twig we're just changing one part so it's you actually have like a parent-child relationship and you can just change the one part you need to change so all you do is you add the code block if you see on the Left there's code block footer
towards the bottom all you do is you add that to your parent template that allows you to override that bit in your child template essentially in the nice thing about this inheritance is it works exactly like class-based inheritance and it's simulating
that and it's fast it's the fastest inheritance in seeming engine implements and I think this is also nice because it sort of gives us justification for also reducing the amount of templates because I think previously the reason for creating all these
little small atomic templates was oh well what if you just want to change this one part so that's not really an issue anymore so I think that will also help us to reduce the amount of templates and again sort of coming back to this it's another part
of redundancy that we have many things templates and theme functions that output almost the exact same thing and we want to consolidate them and use actual theme suggestions which is something we've had in core for a long time but we've never really
[ ... ]
Nota: se han omitido las otras 4.829 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.