 Hai, semua. Selamat datang ke Ketua Ketua Ketua dan selamat datang ke Klik Thao. Terima kasih. Sama lagi. Jadi saya akan bercakap tentang Ketua Ketua Ketua Jadi ini kata-kata benar-benar memperbaiki kamu untuk sebenarnya tahu sebabnya Ketua Ketua. Jadi sesiapa di sini tidak tahu Ketua atau kata-kata? Maaf. Jadi kamu harus tahu tentang Ketua dan sebenarnya kamu harus memperbaiki Ketua Ketua Ketua dengan Jonathan Tuffing kerana Sebenarnya saya ingin bercakap tentang Ketua tapi kemudian saya melihat presentation Jonathan dan bercakap tentangnya. Jadi saya akan bercakap tentang perkara yang tersebut. Jadi anda telah bercakap dengan presentation Jonathan dan saya rasa ia sangat menarik. Saya rasa ia sangat menarik. Untuk apa yang saya ingin bercakap? Kerana ada komponen yang berbeza dan ini adalah pilihan yang tersebut. Jadi pilihan pertama adalah menghadiri dan bagaimana anda menghadiri pilihan yang berlaku, bagaimana anda memperbaiki pilihan yang berlaku. Pada kemudian, kita akan bercakap tentang pilihan yang berlaku, bagaimana anda memperbaiki dan melahirkan pilihan yang anda memperbaiki. Dan kemudian, tentu-tetu saya akan bercakap tentang perkara yang anda tidak tahu tentang pilihan yang berlaku. Cuma anda tahu tentang pilihan yang berlaku, yang tidak pasti mengetahui, jadi saya akan bercakap dengan perkara yang tersebut dan esok yang yang akan saya bercakap dengan pada pilihan yang berlaku. Pertama, pilihan yang berlaku. Berapa banyak perkara yang berlaku kepada pilihan yang berlaku? Hai. Terima kasih kerana mengetahui. Ada sesiapa? An example of template engine? Or any template engine, not template engine? Or just go. Or any template engine? Ya. Template engine. So we didn't go. This is really how it works. You have a client sending a request to the multiplexer. Dengan handle, handle, and start talking to model database. It will send all those things to template engine to generate the content using the template and finally we'll go back to client. So this is where it is. And this middle part here is what I'm going to talk about today. It's supposed to be orange colour. It doesn't come out too much. So a template engine essentially does this. It takes data, ...data, ia mengambil tembakan, ia mengambilnya bersama... ...dan kemudian mengambilnya sebagai konten, untuk menjelaskan bagaimanapun. Kemudian, kembali ke tembakan... ...dia sebenarnya... ...dan kembali ke tembakan, ia sebenarnya... ...tidak sebenarnya, tapi hampir seperti dua tembakan. Satu adalah apa yang dipanggil sebuah tembakan yang tak logis... ...yang seperti masjid... ...hendoba. Jadi, anda cuba sebanyak yang mungkin... ...atau cuba tidak memasukkan logis... ...untuk tembakan. Yang lain adalah, tentu saja... ...JSP, HEMO, JPHP... ...yang lain adalah... ...saya mengambil semua logis di dalam tembakan. JSP adalah... ...basis-basis semuanya. Semuanya di dalam tembakan. Jadi, apakah tembakan yang memasukkan tembakan... ...dan jenis jenis jenis jenis ini? Sebenarnya lebih dekat dengan logisnya dan... ...tapi tidak secara logis... ...sebabnya jika saya memasukkan... ...saya rasa anda akan melihat sedikit apa yang saya maksudkan. Ia memasukkan sedikit... ... Ground Princess Tempakan sebab... ...�� saham passionateys parteak. Bukan dabei saya berkenal dengan hoyang tempat yang saya cachuk untuk memasukkan tembakan. Saya eensienyaitu kita. Dan itu adalah Tata PTK. Namun, ilangnya bukan trespatan.32 lagi dibanyak. Jadi, apakah jenis jenis jenis jenis jenis jenis jenis? Kenapa betulnya jenis jenis jenis jenis jenis jenis jenis jenis jenis jenis? Jenis jenis jenis jenis jenis jenis jenis jenah... ...änir iaito? dan HJML template. HJML template berguna dari template text. Template text basically contains almost everything that you need. HJML template contains those things that are very specific to HJML. For the template engine, there are two parts of it. The first part of it is something you need to put into the handler. So what do you do in the handler? You put two pieces of things. The first part of it is really to pass a template whether the template is a string or a file. So you pass a template. The second part of it is you need to execute the template. So it's just these two things. You pass it and then you execute it. The second part of the template engine is the template files or the template itself. And the template in the simplest form is something like this. Can you see this? So this is HJML. And what you have is double curly brackets. Start and double curly brackets. So this dot looks very harmless and looks very simple. It's actually quite complicated. It's one of the most important things that you need to think about in a template. Sorry, in a go template. Because that basically contains the data that is passed from the handler to the template. So if you say, so the rubius here if you say if you use Rails or you use Sinatra, you have an instance variable. You put an act and then that instance variable is passed on to your template. So here you don't pass on anything at all. The only thing that you pass on, whatever you want to pass on to a template is the dot. So everything, the whole universe is actually in the dot. So everything you want to pass on to a template is in the dot. And whatever you do next with it is basically you manipulate it out. So let's look at some code. This is a handler. And say you have a handler called process. So these are two parts of it. First you pass the template. This is one form of passing. So you're actually passing a file here. But you can also pass strings. You can pass anything. And then after that you execute it. So you execute, you pass on the writer which is basically the response writer. And you pass on the data that you want to pass on to a template. In this case, I pass on a string. Hello world. But in other cases, you can pass on a strut where you can connect on your data. You can pass on a map. You can pass on whatever slides or whatever you want to pass on. So that's the basics It seems very simple. You pass, you execute, you get data and you throw it to a template. Everything is in the dot. What else is there? So it's actually quite a bit of stuff. And at least in my opinion, I think the code template is kind of free because it doesn't actually do what you think it actually does. And I'm going to talk about three things which I think is really interesting. You might already know it if you haven't. Jonathan probably knows it. But these are some things I don't see often or I don't see at all in other template engines. So the first is pipelines. So what I mean by pipelines? Just now you saw dot. Right? It's only a dot. But actually it's more than a dot. You can actually do stuff like this. So you can have let's say P1 is a dot or whatever variable if you get happier. You can pipeline it to P2. So the output of P1 goes into P2 and output of P2 goes into P3. And it's processed in the pipeline. So let me show you an example. Again, HTML. So let's say I have this is a constant across this example. But let's say I have constant 1, 2 dot 3, 4, 5, 6 and I type it to printf and then I have the printf string. This will generate 1, 12.35. So you can actually pipeline the output from 1 to the next and to the next to the next to the next. So pipeline. Any other web template engine you've seen with pipelines? I think Angular. Angular has pipeline? I don't know the symbol but I do remember acting upon the value. Okay, has full test. Yeah, full test. But syntax might not be the same. Syntax is not the same. Yeah, but it's similar. Okay. Yes, Kai. Thank you. Okay. So again, it's functions. Functions in GoTemplateThing. It's a little cumbersome but it actually is again very powerful. So, just give an example here. Again, you have a function. You just said you find let's say you want to format the date that you want to format accordingly. You create a function called format date and then as you before you actually pass a file and execute it, what you do is you add the function, you give it a name, label fdate and then set it as a function using the fung map function. Sorry, the fung function and then you pass a file as per normal and you execute it. Inside your template, you can now use you can now use fdate. Basically what you've done is you've created a function and you pass it on to the template. Of course, it looks a bit cumbersome. Wow. Do I every handler do I need to create my own function and then set it in? Well, you can if you want but you can also put some utilities to automatically create a fung map so I can fold it in. So, this is the method of the way how you use to update a dot so basically you are formatting the date for the dot. That's one way of doing it. Of course, the other way is your dot and then you pipe it to your fdate. And the fdate it comes out of something else can pipe it to something else. You can come up with different variations of it. So, second interesting thing I think about the Go template engine is the the third part. Well, unless you don't have the dot which is where the dot. Unless you don't have the dot just the function. Just the function? I don't have anything. It's an error. You're not passing a parameter to the engine. Of course, if your function does not take any parameter, that's fine. But if your function takes a parameter, that's fine. I thought the fdate didn't have. Or med date. Oh, okay. But the argument is taken as time now. Oh, which is the dot. Which is the dot. Ya. This is the dot. So, you're passing time dot now. To make it a bit clearer, could you go fdate time dot now in your template? You can. You can. You can. I mean, I'm just doing this to show you can type or you can put in any other data in the date. So, I think one frequent use is really you put in stuff in a strut and then you pass a strut as a dot and then within the strut you can actually use the different parts of the strut. So, it's a date and date. The third thing about co-web templates is aware and what do I mean by that? So, when you display the content on a web page, according to where you place it, the formatting of the data changes. So, it is context aware. It is aware of where you are placing the data. So, I'm going to show you the code example. I habitually use this. So, this is basically a string. I ask so, you have angular brackets, you have double quotes, you have single quotes, you have question mark, you have colon. So, it's a test. Now, I put it in this. I put a dot here. Within this, I put a dot in the hash wrap. I put a dot when Q equals 2 and I put a dot under as a JavaScript function. Let's see how it comes out. So, this is how it comes out. As you can see, all of them are different. It depends on where you actually put the data. It comes out differently. So, this is a bit messy. Let's just show your table. The original text is here. And you just put it with a normal div. It converts all the angular brackets into 100% LTE, semicolon and so on. You... What's that called? html? html They call it URL encode. You put it in the hash wrap. Second one is the html encode. Oh, sorry. First one is not. First one is probably call it html. Escape. Html is escaping. You put it in the hash wrap and you put it with the... as a what is it called? Curry string. Curry string. And it changes as well. And you put it in JavaScript. It's a little different. So, it changes according to where you put it. And I would like not actually seen any other about company that does this, though I have to be wrong. This is something I thought is pretty cool. But why would you want to do that? It's not like kind of crazy thing to do. So, obviously this is the reason, right? Because this is a very obvious reason. There are other reasons but this is a very obvious reason. And for this, I actually want to show you a demo. So, let me show you the code first. If you can see. Okay, you just ignore this too. Like if I do this here and I output this here. So, if I put this, right? So, and I have a form that summits. Okay. I have a form that that does this and I have a input that enters some script in it, right? So, normally you should come out with I mean, if you didn't protect it properly, then you actually throw a JavaScript alert. Let me start this. But in this case, what happens is that it converts it into this. So, what happens is basically converts the angular brackets and everything accordingly. And then it just turns out into normal stream. Display it on the browser. Of course, you can actually escape this. So, what happens if we don't do this? So, the other thing is you can you can remove this. You remove the existence protection and you put template.html. Basically, you say, look, this is an HTML. Like, don't convert it. You blow it up again. So, this time. Oh, okay. Sorry. Technical problem. I did not save the file. Okay. Let me compile it again. It comes out. The script actually comes out. So, that was an example of how you possibly use it. In fact, the thing about it is you don't actually need to use it because by default it protects you from this kind of attacks. You can actually escape it if you want to but then you actually need to explicitly do it. So, that was a demo. And end of with a sales page. So, this is my new book. Go Web Programming. This is actually extract one of the chapters in my book and I'm halfway through writing it but it is already in Early Access. If you want to you want to get Early Access and use it discount code if you're 50%. So, it's 5.0. You are aiming to finish this file. So, I should finish writing around July and it should come out around August, September. Okay, a little bit faster. I've been pushed like crazy by the politicians. Go is hot. We need to dilarit soon so, it's to beat the competition. Sending all my minds and opinions during this. Okay. So, that's it from my talk. Thank you. This is my email and my Q&A. He's taking on a know-it type of experience with Go.