complete the function of g_layout method, and add many templates for it