public T locateLayoutTemplate ( String controller , final String layout , final boolean useCache ) throws ViewException { // first see if we have already looked for the template final String controllerLayoutCombined = controller + ' ' + layout ; if ( useCache && cachedTemplates . containsKey ( controllerLayoutCombined ) ) return engine . clone ( cachedTemplates . get ( controllerLayoutCombined ) ) ; // README: computeIfAbsent does not save the result if null - which it actually might need to do to minimise disk reads T template ; if ( ( template = lookupLayoutWithNonDefaultName ( controllerLayoutCombined ) ) != null ) return cacheTemplate ( controllerLayoutCombined , template , useCache ) ; // going for defaults if ( ( template = lookupDefaultLayoutInControllerPathChain ( controller ) ) != null ) return cacheTemplate ( controllerLayoutCombined , template , useCache ) ; if ( ( template = lookupDefaultLayout ( ) ) != null ) return cacheTemplate ( controllerLayoutCombined , template , useCache ) ; throw new ViewException ( TemplateEngine . LAYOUT_DEFAULT + engine . getSuffixOfTemplatingEngine ( ) + " is not to be found anywhere" ) ; }
If found uses the provided layout within the controller folder . If not found it looks for the default template within the controller folder then use this to override the root default template