function build_templates() { global $LANG; if (!$this->build_language_file()) { return false; } Model::load_library('mustache.php/src/Mustache/Autoloader'); Mustache_Autoloader::register(); $m = new Mustache_Engine(); $base_template_dir = APP_ROUTE . "/templates/app"; $template = file_get_contents("{$base_template_dir}/all-templates.mustache"); $rendered = $m->render($template, $LANG); // "Hello, world!" $template_directory = $base_template_dir . "/{$this->language_code}/build/"; $template_name = 'all-templates.html'; $template_full_path = $template_directory . $template_name; if (!is_writable($template_directory)) { AppMessage::set('Template directory is not writable. Please make sure to read the instructions in the Translation section of the documentation before using this functionality'); return false; } $this->version_existing_file($template_full_path, $template_directory, $template_name); $build = fopen($template_full_path, 'w'); if ($build) { fwrite($build, "<script type=\"text/x-templates\">\n\n"); fwrite($build, '<!-- ' . date('F j, Y, g:i:s a', time()) . " -->\n\n"); fwrite($build, $rendered); fwrite($build, '</script>'); return true; } else { AppMessage::set('Error building template file'); return false; } }