 Hi guys Yes, I have really put up Java there That's it's intentional. So Like you might be wondering like why am I talking about templating in Java or like JavaScript? So To give a little background So we had a traditional system in our company like we have been that's been there for almost like 10 years And then we wanted to the revamp the whole UI So at that point of time like we wanted to use the template approach So like the web is moving towards the template and like everyone knows JavaScript is not everyone's cup of tea So not all people who can code they can node these rays So at some point of time you can't really choose node as your server side language So I have to go with other languages like Java Ruby or Python. So we wanted to go with Java so like We figured out we will try to use a template which has both server side and client side support And these are the popular client side templates which are available right now So how many of you guys use at least any one of this either moustache or handle bar or something So like you all all you guys know these are all dominant client side libraries So let's say if you want to use them in the Java So you have no direct way so either you have to someone has to provide you a jar Which is very hard to find because not all JavaScript developers would want to develop something something for Java people So you'll have a trouble with finding the jazz jazz for this particular templating libraries. So We come to like I'll skip this talk if everyone is Agreed that why do we need a server side rendering as well So we have a like everyone now these days like use ember and then angular everything is client side At some point of time you need to consider about server side as well because there are a lot of various aspects that you need to look into so a couple of them are like First loading of initial pages. So whenever if you are using everything in angular By the time like you won't fetch the data will be just showing the loading icon. So that might not be Fine to some of the applications in that applications. You have to really think about providing the server side rendering as well And then like for angular and images I think like people always have trouble finding the ACO for that and there are a couple of alternatives like using quantum JS or some of the libraries like pre-render which internally whenever For a CEO it internally computes that page using phantom.js and then renders it but it's not going to work For all the if the tweet works if you're using a node.js on the server side Else it's out of question So again, like we'll come to templating in Java So if you guys like have a coded in Java like the major templating that we probably would have used is like jsp So does that mean that no, I have a my UI. Do I need to write a code whatever the template both in moustache? And then whatever the dust or whatever the library and the repeat the same thing in the JSP as well, which is going to which it's not a advisable solution because like you're not following the principle of dry there So what we essentially want is the same templating library what we do it should be it should work on both server as well as and the client so like There are a lot of templating libraries and then you can go and figure out if they have a particular jar for you as I said It's not pretty easy to find them so again The question I'm trying to answer here is some of them has jars If you look at the honestly, we don't need jars at all to have any of this templating for the client side libraries because for a long time Java has a internal engine JavaScript engine that you can use to compute Run JavaScript and people have predominantly used it to evaluate dynamic expressions So we can use that and then the problem with like again on the side note So always like jars what happens is you'd like even if you find a jar You'd like you don't you don't look further to use it. So the similar case in the NPN as well. So if you try to use like a lot of jars and a lot of Packages you'll done it to trouble. So this was just a side note So again, like JavaScript 8 Java 8 has a national engine. That's one of the Engine underlying engine which supports a ECMAS script standard. It doesn't really support ES 6 So but it supports till ES 5. So apart from all your crazy Generator stuff in JavaScript, you can run pretty much everything in the server side as well So this is the simple example I hope it's visible to everyone The first part of the code is the script.js. That's the plain JavaScript file and the second part I have a Java code. So what I'm doing is like I'm getting an instance of the the national engine And I'm telling I'm passing I invoking a function with some parameters. It's as simple as that So this is just a hello world example. Let's move to another example So if you take a custom like pretty complex example, what you can do is like you can create a Context we can say that for example, it's I want to use it Does just does the js templates are some other templates You can create a context where you load all your template files and then pass the data and then computes the HTML that is the example and Again here like it's it's split into different pages. So what I'm doing is here I'm creating a binding and I'm passing a named json. If you go back to the previous previous slide So we had that hello name you have the new message. So what that name and count thing we are passing it as a variables in the Java the next slides, please Yes, so again Another slide So how about data like when we talk about templates, right? You have a Template and all you do is pass the data to it. So on a Java and the client said we never had a problem because we use JavaScript Jason javascript object notation But on the server side, you can't really you have you have all your Java objects So for that what you can use you can use any of the porters which converts your Java objects to Jason one of the petty known Library is Jason you can use that library to compute the Jason presentation of your Java model and they can pass that to the template and that's it. So these are the references