/** * Return a mustache template, and all the strings it requires. * * @param string $component The component that holds the template. * @param string $templatename The name of the template. * @param string $themename The name of the current theme. * @return string the template */ public static function load_template($component, $template, $themename) { global $DB, $CFG, $PAGE; $params = self::validate_parameters(self::load_template_parameters(), array('component' => $component, 'template' => $template, 'themename' => $themename)); $component = $params['component']; $template = $params['template']; $themename = $params['themename']; $templatename = $component . '/' . $template; // Will throw exceptions if the template does not exist. $filename = mustache_template_finder::get_template_filepath($templatename, $themename); $templatestr = file_get_contents($filename); return $templatestr; }
/** * Helper function for getting a Mustache template file name. * Uses the leading component to restrict us specific directories. * * @param string $name * @return string Template file name */ protected function getFileName($name) { // Call the Moodle template finder. return mustache_template_finder::get_template_filepath($name); }
/** * @expectedException moodle_exception */ public function test_invalid_get_template_filepath() { // Test something invalid. $dirs = mustache_template_finder::get_template_filepath('core/octopus', 'clean'); }