Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
Mustache_Loader_ProductionFilesystemLoader Class Reference
Inheritance diagram for Mustache_Loader_ProductionFilesystemLoader:
Mustache_Loader_FilesystemLoader Mustache_Loader

Public Member Functions

 __construct ($baseDir, array $options=array())
 Mustache production filesystem Loader constructor.
 
 load ($name)
 Load a Template by name.
 

Protected Member Functions

 getFileName ($name)
 Helper function for getting a Mustache template file name.
 
 loadFile ($name)
 Helper function for loading a Mustache file by name.
 
 shouldCheckPath ()
 Only check if baseDir is a directory and requested templates are files if baseDir is using the filesystem stream wrapper.
 

Constructor & Destructor Documentation

◆ __construct()

Mustache_Loader_ProductionFilesystemLoader::__construct ( $baseDir,
array $options = array() )

Mustache production 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',
    'stat_props' => array('size', 'mtime'),
);

Specifying 'stat_props' overrides the stat properties used to invalidate the template cache. By default, this uses 'mtime' and 'size', but this can be set to any of the properties supported by stat():

http://php.net/manual/en/function.stat.php

You can also disable filesystem stat entirely:

$options = array('stat_props' => null);

But with great power comes great responsibility. Namely, if you disable stat-based cache invalidation, YOU MUST CLEAR THE TEMPLATE CACHE YOURSELF when your templates change. Make it part of your build or deploy process so you don't forget!

Exceptions
Mustache_Exception_RuntimeExceptionif $baseDir does not exist.
Parameters
string$baseDirBase directory containing Mustache template files.
array$optionsArray of Loader options (default: array())

Reimplemented from Mustache_Loader_FilesystemLoader.

Member Function Documentation

◆ getFileName()

Mustache_Loader_FilesystemLoader::getFileName ( $name)
protectedinherited

Helper function for getting a Mustache template file name.

Parameters
string$name
Return values
stringTemplate file name

Reimplemented in core\output\mustache_filesystem_loader.

◆ load()

Mustache_Loader_FilesystemLoader::load ( $name)
inherited

Load a Template by name.

$loader = new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views');
$loader->load('admin/dashboard'); // loads "./views/admin/dashboard.mustache";
Parameters
string$name
Return values
stringMustache Template source

Implements Mustache_Loader.

Reimplemented in core\output\mustache_filesystem_loader.

◆ loadFile()

Mustache_Loader_ProductionFilesystemLoader::loadFile ( $name)
protected

Helper function for loading a Mustache file by name.

Exceptions
Mustache_Exception_UnknownTemplateExceptionIf a template file is not found.
Parameters
string$name
Return values
Mustache_SourceMustache Template source

Reimplemented from Mustache_Loader_FilesystemLoader.

◆ shouldCheckPath()

Mustache_Loader_FilesystemLoader::shouldCheckPath ( )
protectedinherited

Only check if baseDir is a directory and requested templates are files if baseDir is using the filesystem stream wrapper.

Return values
boolWhether to check is_dir and file_exists

Reimplemented in core\output\mustache_filesystem_loader.


The documentation for this class was generated from the following file: