concept logic in category ext js

appears as: logic, logic
Ext JS in Action, Second Edition

This is an excerpt from Manning's book Ext JS in Action, Second Edition.

Next, you instantiate an instance of XTemplate , which looks much like the last Template configuration, except you encapsulate the div container with a custom tpl element with the attribute for, which contains the value "." . The tpl tag is like a logic or behavior modifier for the template and has two operators, for and if, which alter the way the XTemplate generates the HTML fragments. In this case, the value of "." instructs the XTemplate to loop through the root of the array for which it’s passed and construct the fragment based on the pseudo HTML encapsulated inside the tpl element. When you look at the rendered HTML, you’ll see no tpl tags rendered to the DOM. The results of your efforts are identical to the template example, as shown in figure 2.8.

You then test to see whether the grid has a rowCtxMenu property, which on the first execution of this method will be false, so the interpreter will dive into this branch of code. You do this because you want to create the menu once if it doesn’t exist. Without this fork in the logic, you’d be creating menus every time the context menu is called, which would be wasteful.