 So today I'm going to talk about twig giving you some tips and tricks. I'm Fabien, I'm the the creator of Symphony and the creator of twig and today we're not going to talk about the basics because I think it's covered pretty well in the documentation, the twig documentation and the Drupal one as well. So instead of that I want you to give you some tips and advanced features that might help you in your projects. First of all I want to talk a bit about the project's lifecycle because I think it's very important to understand what to expect from an open source project and the very first thing I want to talk about is backward compatibility because that's probably one of the main feature of twig and when I'm talking about backward compatibility I'm talking about the language, the twig language, the language you are using in your templates but I'm also talking about the code itself, so the PHP code that runs and executes your templates. So the main core language, the main concepts haven't changed since twig 1.0 which was released in March 2011 so more than six years ago so stability is very important for me. That doesn't mean that this is the exact same twig that we had six years ago because of course we added a lot of features and we did a lot of improvements and actually we release on a very almost every month new version of twig so right now the current version is 133 so as you can see we have many versions so we are using semantic versioning which means that whenever there's a bug fix release we release a patch version so 1.x.y and whenever we are adding a new feature then we bump the minor version. Okay so we release very often almost one release per new feature or big bug fix and that's possible because we keep backward compatibility which means that upgrading from one version to the next upgrading from 1.2 to 1.28 should be very easy it should not break anything in your code especially if you are only using twig as a template system and you are not messing up with extension or whatever and if we break something if we break backward compatibility and that happens in advantage it's not on purpose then we can fix and release a new version really quickly that happened actually last week I think where we broke backward compatibility for a very an edge case I would say that actually affected Drupal 8 and we were able to actually fix the problem really quickly and release a new version which means that between the time we released the version with the problem and the time we released the version with the fix I think it was less than two days so upgrading it should be in a brainer and that's very important so if you are still on an old version of twig I only encourage you to actually upgrade to the latest version because also we are trying to improve performance and things like that. Okay as you might know we released twig 2.0 in January this year it's not a big release in a sense that so the first feature is that we dropped PHP 5 support so it's only PHP 7 plus we improved performance mainly the file system loader so the impact is quite interesting and of course the performance is improved if you are actually upgrading to PHP 7 we also dropped deprecated features and that's the exact same we are doing deprecation in the exact same way as symphony so whenever we want to remove a feature or change the way it works in twig I we actually deprecate the feature so that you can get some feedback in your log saying okay you are using this feature is going to be removed in the next major version so twig 2.0 is the exact same set of features as twig I the latest version of twig I minus all the deprecated features okay and twig 2.0 is also about a lot of internals refactoring but I think you don't care about that you should not care about that anyway okay so and so backward compatibility and the fact that we are releasing very often is part of the philosophy of twig and the other part of the philosophy I want to talk about today is that we have a small core we only have three different way of expressing something in a template so you can say something you can do something or do or say nothing so that's the commence so the first two are very interesting the third one not that much and if you have a look at how that's done we have a very small set of tags so the first one is what we call a tag in twig we have a very default set of small set of default tags and for when you want to say something we have just one concept which is an expression and an expression is composed of a lot of things can be strings and numbers and whatever but we also have tests filters and functions that's all that's all the concept that you need to understand to really master twig and everything is actually an extension which means that by default twigs comes with no tags no test no filters no functions everything can be defined via extensions even the operators so plus minus and so on they are defined in an extension and of course twig comes with some core extensions that are enabled by default but you can disable them if you want so it's really a small core by default we also want to control the feature set that we give you out of the box because we want to be web designer oriented so it's not really we don't want to duplicate PHP in twig quite the contrary actually and we are trying very hard to not have features that depend on the type the underlying PHP type for instance so we'll say I'm going to talk about that a lot during this presentation and that's related to doing the right thing by default so no types means that as a web designer you should not care about the fact that the variable is an array a PHP array or an object for instance a string or an array and I'm going to give you some examples so the first one is that's an example and it's also very interesting because it has a big impact in terms of performance so twig is quite fast because we actually compile we convert your twig template to PHP code so it's really fast there is one thing you need to be aware of and that's the way you actually access variables so that's how you can access a very simple variable in twig so here we want to display the author I created at time and permalink okay so the overhead for that kind of templates is really small because at the end of the day it's just PHP code but now if you're using the dot notation and you should use it a lot really it's two things first is the way you can access things from a variable but it's also the slowest part of twig actually so content dot links can mean a lot of different things so it can be the links item for content if content is an array or extends a reaccess it can be the links property on a content object or the links method or to get links is links or as links method so that's a lot right and by the way the last one is only available as of twig 2.0 so this is how we actually resolve the dot notation and that's what I was talking about you should not care about if content is an array or an object you are using the dot notation and that's an abstraction that we give you that's nice but then of course there's an impact on on terms of performance so the first tip is so there is always a trade off between performance and abstraction and here what you can instead of saying content on links if you know that content is actually an array you can say okay I want to use the first one I want to use I want to get the links item from the content array it's less flexible because if at some point you want to change content to be an object you need to change the template as well which is something we want to avoid and that's avoided if you are using the dot notation but if you are in a tight loop for instance it might make sense to actually use those things so if you are adding parentheses at the end it means that's a method on an object okay so less flexibility but more performance and of course don't change all your variable accesses with these kind of things by default use a dot notation and if you are in a tight loop and if you can measure that actually you would have again in terms of performance by switching to a more specific call then do that the next tip about performance and that's also related to the dot notation as the dot notation is what is really slow in twig or slower than anything else it's not really slow it's just more it's slower than anything else what you can use before PHP 7 is you can install the C extension so we have a small C extension that replaces the dot notation and it's way faster than the PHP code you can expect an increase of about 15 percent it really depends on the number of dot notation that you are using in template of course it's only available for twig 1 because twig 2 is only for PHP 7 and as of PHP 7 the PHP code is actually as fast as the C extension right so you don't need the extension anymore in PHP 7 how many of you are actually using PHP 7 in production right now okay so you should upgrade now I mean it's free performance for free it's compatible great new features so I think that just makes sense okay so the dot notation is great but sometimes and especially in Drupal you have special variables like you know dash something and of course you can't no not of course you can't do dot dash markup it doesn't work in such a case what you can do is you can use attributes so attributes a function defined by twig and you can say I want the markup the dash markup attribute on the site whatever variable you want right that's the someone line here or you can use the array if you're using the attribute function it's exactly the same as a dot notation so markup can be an array item or a method call or whatever the last one is also interesting and that's the first use case for the attribute function is to get a dynamic attribute on something right so var here can be whatever you want and of course you can't say something that var because var would be interpreted as a string and not the value of the var variable right okay another great tip for performance and that's available as of twig twig 126 and I think the latest version of Drupal 8 is on twig 132 so it's available in Drupal 8 3 is that so when we when you create an extension and that's also only if you are creating extensions so an extension is a way to create new test new filters new tags for your templates so by default an extension is about the definition of your new filters tags and functions but it's also about the runtime implementation and the runtime implementation can depend on services services that are expensive to create but as twig creates all the extensions even if you are not using some of them it can cost a lot to actually just create the extension and the dependencies so what you can do as of twig 126 is to actually decoupled the definition from the runtime extension the runtime implementation if you are doing that the runtime implementation will only be included and the dependencies will be created only if you are using some of the things defined in the extension so you can have a look at a symphony code base for some examples okay the next topic I want to talk about is defensive programming this one is kind of interesting is so whenever you are using variables sometimes a variable does not exist and so what are you doing if the variable does not exist or if the variable is empty what is a default value and things like that so when you check if variable like the first example here it checks that the variable is not null or empty or zero right so if that's the case then you enter the if condition but that only works if variables is actually defined if it is not defined you will get an error the second one is almost the same as first one but here we are saying okay we are checking that the variable is not null empty or undefined but if it's not defined then we have the default value here which would be a user and you can be explicit with is defined so here if you are not sure that the variable is actually defined by the PHP code what you can do is checking that the variable is actually defined so that's a good practice if you're not sure that the variable is actually defined in Drupal 8 if you enable the debug mode for each template you have as a command at the top of the file all the variables that are actually defined and that you can use in any given template so we have a bunch of save quotes like you can check if a variable is null or if it is empty and the last one is something I don't recommend you to use because it's related to the type of the variable is same as means I want to check that this is this is really zero the integer zero not the zero as a string if you are not saying same as you know PHP doesn't care if zero is actually a string or an integer so it would be true in both cases and sometimes you need to be sure that is actually this exact value and exact type I again I do not recommend you to use that but I think it's interesting to know that it exists if that makes sense for you when you iterate over a collection the for loop is almost the same as in PHP but we have some more features like you know you iterate over a collection and if there is nothing in the collection then there is an else so you can fall back to something else even more interesting is that you can add a condition in the for loop so I want to iterate over all the items in collection only if item is actually published and the else is going to be enter if there is no published items in the collection so that's we're trying to find ways to give you more ways to express what you want in less code that's one of the main goal of template system actually okay I'm talking about checking things and be sure that everything exists when you include a template into another one you're not sure if your menu the twig actually exists this one is probably exists because you know it's it's it's just a string static string but sometimes you want to include a dynamic one so you want depending on the user name here I'm going to include a different template right so till day here means concatenation right so users slash the username and slash and bio the twig but if the username directory here does not exist then you will have an error so the way you can fix that is that first you can fall back to other templates so you can say so here the way it works is I want to include the first template but if it does not exist then you can fall back to the second one and if the second one does not exist then you can fall back to the third one so it's great if you have a default template that you can use so if the user actually want to customize a template you can you will add the first one if not you can fall back to default one that is the same for everyone okay but sometimes it's not really possible to provide fallback it's just if it's there you need to include it if it's not there then you should not do the include so you want to ignore the fact that there is a missing template so that's possible as well so that's the first line here and on the slide you include a template but you ignore if it is missing which means that if the template does not exist it the output will be nothing just an empty string right no error nothing it also works with a lot of different constructs and I'm going to talk about those constructs later on okay okay so those are the filters defined by Drupal 8 by default and of course at some point you know so Drupal will add some more of a time and and it could be the case that at some point some of those could be deprecated so for instance the Drupal underscore escape I would really like to remove that one and just use the standard escaping mechanism from twig we don't know so right now it exists but perhaps and in one two three or in the next major version it's not going to exist anymore in twig we have a mechanism to actually declare that a filter is deprecated like this so we say here we have an old filter is deprecated and the new one is that a new filter filter right and those deprecation notices they are using the same mechanism as the symphony one and Drupal one I'm not sure and I'm pretty sure it's not displayed yet or logged yet but it's there which means that if it happens some point Drupal you will have a log saying okay it still works now but you must know that in the feature probably next major version you need to upgrade from these old filter the new one right so it's great because it still works and it gives you time to actually upgrade your code to the newest way of doing things without breaking things badly when you upgrade to the newest major version okay this one is also interesting sometimes you want to check if a block exists or not and I wanted to talk about this one because it's about consistency and auto discovery so here is defined I've talked about that before if a variable is defined but you can put a lot of different expression before is defined and twig tries to do the right thing so here I want to know and I think it's quite explicit really if the block title is defined then we include a block if it does not exist then the condition is false so it we are doing a lot of things like that and it's it's brand new actually but it's great for consistency it's a new feature and auto discovery is great because you can probably guess that if that should work actually it works okay I like this one it's not really a tip or feature or whatever but I get so many issues about this one that I need to talk about it so basically that's on the left side this is a twig template it's really just HTML and the HTML version is exactly the same right but you probably have something like that right and you want indentation for your twig template and it generates that code which is not intended the right way does it matter no no way it matters we don't care we don't care about that but I know that a lot of people actually care about those kind of problems because I have a lot of issues about how we can fix that there are many ways you can fix that the first one is you can unindent things in the twig template so that the generated code is actually done in the right way or what you can do is you can add minuses here like that and on the left side and that would remove the spaces right I would not recommend to use the space list tag because this one is kind of slow because it needs to parse things in there to remove all the white spaces so the one on the left is done at compile time the one on the right side the space list tag is done at runtime right so that's the big difference that's my advice I mean I think that makes sense because you are working on the twig template so that's where the code should be nice and clean you're not working on the HTML pages and okay I'm going to tell you something the browsers they don't they don't care and it's not it's not about optimization because sometimes people are saying okay but I want my HTML code to be to be optimized so I want to remove all the white spaces if you want to do that then you can probably compress the HTML and it's going to be probably much better than trying to optimize the white spaces but sometimes you do want to add some white spaces like this this is an example in Drupal sorry so here you can see that I don't have a space a white space between h2 and the title attributes here why because if title attributes is empty then I have a nice h2 tag right no spaces and if title attribute is not empty then title attributes actually adds the space so again the HTML is clean but the the template is not so I would not recommend do that and okay so now that's how I think it should be and again I mean that works that works you get the point all right okay next one here again I don't have the white space and you can see that if I want to add a name then I want to add class hidden two problems here the first one is the white space but second one is that I have some HTML attributes in a string which is not good right HTML should be HTML twig is something else right should be separated so what I would like to do is this which is much better now the HTML attribute is in the HTML part and twig is only responsible for displaying the hidden or outputting the hidden string or not and again having a class an empty class here is not a problem and actually I did a check okay yeah okay oh okay I want to talk about this because okay so that that's how you can debug things I thought I removed that from the presentation and I decided to not talk about that because there are several pages in the Drupal 8 documentation just about that so and documentation is pretty good so I don't need to talk about all those things escape this one is way more interesting actually how can you reuse templates and that's very important because I think that's one of the main selling point of twig versus using PHP for templates we have many ways to reuse templates because of course you don't want to copy paste things in your templates or at least not often so we have many different ways you can use things I think extends and include are the two main ones macro sometimes embed I'm going to talk about this one because it's not easy to understand sometimes set you should not use set so if if in a template you are assigning an HTML snippet of code into a variable that's a big no-no you need to switch to something else it means that you need an embed most of the time or an include or whatever but don't use set for trying if you are trying to use some piece of code I will give you one example where it might make sense to use set okay extends that's the easy one I think everyone knows about this one it's like inheritance PHP so you have a bunch of pages and you can see that most of the pages have the same layout so you have one layout plus the contents that you want to be different depending on the page so the way it works in twig we have a template with two blocks so a block is really a hole in a template where you want to be able to change the content depending on the page you are working on so that's kind of an abstract thing the layout will never ever be displayed by default right you need to extend it and put something into the block tags and acne website here is just a default value if you do not extend it in a template so now this is a real template that I want to display it extends the layout and then I am defining the blocks the title block and the content block if I'm not overriding the title block the default value defined here would be displayed okay so that's a great way to create the main layout of your website or theme whatever and if you have a more complex website you might want to actually have several layers of layouts that works as well so layout can extend another layout and that's how you can you know customize your layout and be more precise and depending on on the website so you can have one main layout then you can have layouts for each sections of your website and then pages you can have as many levels as you need actually so that's the first way you can reuse things the second one is include so include is really like in PHP so you store a snippet of HTML and you want to include that into many different templates so it's more about being able to reuse fragments of code it works well for site bars or menus if they are not part of the main layout of course if if they are part of the main layout then you don't need an include includes are also great if you want to decouple things or if you have a very large template with large chunks of HTML code you can you know just extract that part of the code into an include that's also a great way to organize your templates so it's not really about reusing things it's more about organization okay a macro is a bit like an include the big difference being that you want to be explicit about the variables you expect in the HTML snippet so here I could use an include for that kind of things but here I want to be able to customize the ID the level of the type and I want to be explicit about that and you can't do that with a macro because a macro has a name and it takes some arguments right that's the big difference with the include yes include can also take variables but it's less explicit than macro and the other difference with include is that you import a macro and then you can use the macro underscore self means that I want to import a macro from the current template and not from an zoop template sometime it makes sense and if you want for for bigger websites I recommend you to create one macro twig template or several ones where you store all your macros that are used on your website makes sense if the website is more complex of course okay embed this one is very tricky actually it's a mix between extends and includes sometimes it makes sense to use that and this is the typical example where it makes sense you have a grid based design and you want to be able to reuse some of the structure of that web design so for instance here we can see that we have two different pages and the first red block is exactly the same in terms of structure not the contents the structure is the same for both pages and I don't want to copy paste the structure on the two pages and even on the second one you can see I have three lines with the exact same structure and again I want to do that and be able to reuse the same structure so you can't use include because when you include something you are including the structure plus the contents so that doesn't work you can't use extend because if you are extending your grid as you see on the second pages second page the example we have three times the same structure and you can't extend several times for the three lines so that doesn't work as well so we need something else and some something else is actually using embed so the first thing is you define a template which is just a structure so it looks like a layout really right with blocks first part and then in your template you don't extend your embed so you include the template and you extends because you want to be able to define the contents for each blocks yeah does that make sense not at all I knew it I mean it's not easy to really understand that so let me try again so I think I'm going to talk about the second example on the right side here I have three lines each line as the exact same structure HTML structure but of course the contents of the boxes are totally different I want to be able to reuse the structure for each line and be able to actually change the content so what I do is I create a template which is sorry this one this this is just a structure of a line right I have div and three blocks okay but as you can see the three blocks are empty so there is no contents in there it is just about the structure and then I need a way to actually add this structure three times with different contents all right and that's where you are using the embed tags so on this example I would have three times this embed block each time with different contents it means it means that the final template would have the contents but not the structure because the structure is defined in another template is that better makes more sense okay so we have documentation on the tweak website so you can read it again and I think you really understand how it works when you are actually trained that on a very your your own templates and examples and okay I understand now okay wow time flies okay so just one quick example and when you you can use set is for navigation for instance so if you have a navigation that is actually repeated on the page and you don't want to put that into an include an include would be better but you don't want to do that because it makes the template less readable right because you need to have to reference another template to and go elsewhere to actually see the code what you can do is you can set the navigation in a variable and then displayed twice I will not recommend that but sometimes you don't have a choice or that's easier okay next up is dynamic templates so when you include a template or when you extend a template the parameter is actually a string and the string is actually a path to a template on your file system or at least most of the time that's how it works but sometimes the templates are stored in a database or you want to define a template directly into a template why not that's the example of here here I'm setting a variable code with a template as you can see that's a tweak template right and then I want to be able to include that so what you can do is you can use a template from string function what it does behind the scenes it takes the code it parses the code it creates a PHP class which is a template as any other template so that's fast it's not like ever in PHP right and then you can include a template so it means that include and extends and embed takes a string or a template which is a PHP object that you can create directly from a trick template with template from string so this one is also very interesting if you store your templates in a database because you can then load the templates from the database in your PHP code pass the templates to your templates and then include them directly like that okay and you can do whatever you want so you can modify the templates if you want you can do whatever you want really in the tweak template and then include that okay source source is very so this example is not great because I should have taken as an example but source is like include but we do not evaluate the template so source is really about getting some piece of text and including directly without evaluating the template as tweak right include we evaluate and we display we out the output is really the the template evaluated source we take the content as a blob we don't care about what what's in there and we just output the the block the blob directly into your template okay so this is a website and the two white boxes can be customized by admins or end users so in the admin you have sorry a text box when where people can actually put some tweak so they can put some tweak syntax in there the problem is that you can't trust those templates right because they do have access to all your variables so potentially they can you know if you if you have an object in there with a delete method they can call that and you don't want that so in tweak what you can do is you can sandbox your templates and and the sandbox it's only for untrusted templates of course and it restricts what you can do within the sandbox so we have a policy where you can say exactly which methods which filters which tests so everything and remember everything is actually part of extensions which means that you can disable everything even for if that makes sense for you that's possible okay so that's that's the way it can be safe so the way you can do that is we have a sandbox tag or you can put or we can pass an option which is sandboxed equal true if you are using sandbox then we are going to evaluate your tweak code within a sandbox and the way you define your security policy is by creating a PHP object as you can see here you can define exactly so by default everything is empty so you are you have access to nothing so you can't do anything so you need to actually customize that and say here are the tags that I can use the filters the methods of properties and the functions and you pass that to the sandbox extension so this is a white list so by default there is nothing you can't use anything so here is a very quick example where you define which tags and templates and methods you can use in your code okay I think I'm going to switch this one this one this one is interesting when you manipulate date and you want to change time zone you can do that with that time zone thing and it can also depend on user time zone that's something you can do with date filter and the date filter is very different from the date function like you can see here if you want to compare that date then you can do that like this if the start date is more than now that's how you can do that so you can compare that date and you can also modify dates so here I want to say okay early birds and at 15 days before the event actually starts so I'm talking a lot about HTML templates but of course Twig is not just for HTML templates can be for JSON XML txt whatever twig does not care about the content of your templates that's not true because we have the escaping mechanism and if you are doing HTML then twig knows how to escape HTML attributes and JSON and CSS and JavaScript and thing like that but that's very interesting for emails for instance that that's how I'm actually managing my emails each email is actually one template where I define that's just a very simple example the subject the body HTML body text so here we are using blocks not because we are in a layout just because I want to define three different pieces that I'm going to use in a different way so I'm never ever going to actually display such templates it's just nice way to actually separate different blocks of contents and then this is how you can do that so by default if you want to run the template you are using the random method but as of twig 28 1.28 what you can do is you can render just a block so then you can use Swift Mailer or whatever you are using to send emails and say okay here is a subject here is the HTML version here is the text version and you can inject that into your email right quick tip that only works or it's guaranteed to work as of twig 128 not before and you need to use the load method and not the load template method okay if you want to learn more about that and why that's the case you can have a look at the code but basically load returns an object where we guarantee that render and render block are going to be stable and we know what we are doing with that the previous method was to use load template which returns an internal object where render block was actually or is actually an implementation detail that can change over time that's why do you want some more cool features thank you first last we have a lot of things like that shortcuts if you want the first value of an array or the last one we will do that quick test if you want to check if a URL starts with or ends with or matches a regular expression that's nice if you want to check that something is in something we have an in test so if password is in username so you can see that we are talking about strings here or if a method is in an array so again in works with strings and objects and arrays it works like you would expect it to work actually name parameters this one is very interesting so in PHP and in tweak by default you pass arguments like this so you convert uncoding and you have two arguments who knows what the first argument actually is is it the original car set or the target who knows I don't know and that that's very that that's that's a problem you don't know which is the original car set and the target and actually if you have a look at icon and and the string they have the same function and the order is not the same yeah so what you can do in twig and that's not possible in PHP is that what you can do is you can be explicit about the name of the arguments right so here from and to and we don't care about the order anymore because you are you are explicit about the argument names right and those names are actually the names in the PHP signature so which means that in PHP text there are from and there are two arguments that's even nicer for when you want to pass an argument which is not the first one and for the other ones you want the default values right so here the first example I want to ignore the missing template so and that's the last argument so I need to put the default empty variables and with context you need to know that true is actually default and then I can say okay I want to ignore the missing template so that's the first problem the second one is you're not very explicit which means that if you don't know the signature by art and I don't know the signature by art empty empty array and then true true you don't need what that means right true true that doesn't mean anything right so what you can do instead is you can use named arguments and then you don't need to take care about the default ones can say ignore missing or true and I think the second one is more explicit and much better than the first one dynamic functions and filters so when you define a new function or a new filter you can use a star and that means that it's going to match anything underscore path so for instance product path or article path or whatever you want so it's a great way to define default dynamic functions and filters don't do something I've seen in the past which is star PHP underscore star star being any PHP function you can they should not okay and then the first argument you get in the function is actually name so that's that would be product here or article okay doing things in batches so going very quickly now so sometimes you you have an image gallery for instance you have two lines with three things and you want to iterate over those but you want to display it like this so what you can do is iterate over all the images and if I is actually divisible by three then you create a new div and then you close the div right so you have every three images you have a new line right that's kind of ugly right there is a much better way you can say I want the images by batch of three right and then all of a sudden it's clear it's it's clean and and very readable okay hmm you can have a look at documentation for this one right so we have a bunch of turner operator the first one is the basic one and then we have a lot of shortcuts depending on what you want to express the last one is very interesting it was added in PHP as well it means if the expression is defined and evaluate to something that is not false then that's what we want and a is actually a default value yeah so in turn place you want to use the first one and not the second one again it's it's cleaner it's easier to understand talking about again consistency and auto discovery and you know things that just works the way you expect it to work we have the brackets notation which is really a combination of or a slice and end the substring and substring it works with arrays you want the first three one the last three ones it also works with strings and actually type you know does not matter so it works with objects that implement a countable or object that implement a two string method or any object and the length of any object is actually one why not but that doesn't the last one does not really make sense of course dynamic so I'm talking a lot about dynamic stuff today so the first one is how you can create a map a is the key b is the value quick tip the you don't need the quotes around a a the second example is the accident same as the first one a is a string and and the question very often asked question is how can I have the key as a variable just put parentheses around that and you can put whatever expression you want I would not recommend to actually have dynamic keys but sometimes you need that so that's also possible new thing added recently in in twig it's that's heinous copes you can have a look at that in the documentation loops everybody is aware of loop the loop variable in twig yeah okay no no this one is more interesting so if you have a loop in a loop in a loop in a loop you can get backward if you want to get the loop variables so the first one the first loop is actually the loop variable for the second for loop and if you want to access the first one you can get loop dot parent which returns the context of the parent scope and then say I want to loop on that so it looks weird loop that parent loop but it's really just the loop of the parent okay again oh okay so this one is I've already talked about this one so instead of you know having several non-named arguments I would recommend to use names so that you really understand what we're talking about here but the thing is the more you are adding options the less easy is the PHP code the underlying PHP code so because you you need to actually define all those possibilities but sometimes you have many of them or an unlimited number of them really in that case what you can do is you can use a variadic parameter like this so you have just an array and it gets all the values and that works because of the options at the bottom of the screen is variadic to true that means that instead of having each argument one after the other I want all the options in one ray and then you can do whatever you want with that okay that's all I have for today that's a lot I really recommend you to actually have a look at the documentation tweak documentation Drupal 8 documentation because everything I've talked about today is actually part of the documentation if you are here on Friday the sprints and that's all thank you