public static function findTemplate($stack, $action = NULL) { $template = strtolower(\Staq\Util::getStackSubQuery($stack, '/')) . '.twig'; $template = str_replace('_', '/', $template); if (!empty($action)) { $template = $action . '/' . $template; } $folder = strtolower(\Staq\Util::getStackType($stack)); while (TRUE) { if (\Staq::App()->getFilePath('template/' . $folder . '/' . $template)) { break; } if (\UString::has($template, '/')) { $template = \UString::substrBeforeLast($template, '/') . '.twig'; } else { $template = 'index.twig'; break; } } return $folder . '/' . $template; }