Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

(no description)

File Size: 135 lines (4 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Mustache_Loader_FilesystemLoader:: (5 methods):
  __construct()
  load()
  loadFile()
  getFileName()
  shouldCheckPath()


Class: Mustache_Loader_FilesystemLoader  - X-Ref

Mustache Template filesystem Loader implementation.

A FilesystemLoader instance loads Mustache Template source from the filesystem by name:

$loader = new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views');
$tpl = $loader->load('foo'); // equivalent to `file_get_contents(dirname(__FILE__).'/views/foo.mustache');

This is probably the most useful Mustache Loader implementation. It can be used for partials and normal Templates:

$m = new Mustache(array(
'loader'          => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views'),
'partials_loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views/partials'),
));
__construct($baseDir, array $options = array()   X-Ref
Mustache filesystem Loader constructor.

Passing an $options array allows overriding certain Loader options during instantiation:

$options = array(
// The filename extension used for Mustache templates. Defaults to '.mustache'
'extension' => '.ms',
);

param: string $baseDir Base directory containing Mustache template files
param: array  $options Array of Loader options (default: array())

load($name)   X-Ref
Load a Template by name.

$loader = new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views');
$loader->load('admin/dashboard'); // loads "./views/admin/dashboard.mustache";

param: string $name
return: string Mustache Template source

loadFile($name)   X-Ref
Helper function for loading a Mustache file by name.

param: string $name
return: string Mustache Template source

getFileName($name)   X-Ref
Helper function for getting a Mustache template file name.

param: string $name
return: string Template file name

shouldCheckPath()   X-Ref
Only check if baseDir is a directory and requested templates are files if
baseDir is using the filesystem stream wrapper.

return: bool Whether to check `is_dir` and `file_exists`