Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
core\output\mustache_engine Class Reference

Custom Moodle engine for mustache. More...

Inheritance diagram for core\output\mustache_engine:
Mustache_Engine

Public Member Functions

 __construct (array $options=[])
 Mustache engine constructor.
 
 addHelper ($name, $helper)
 Add a new Mustache helper.
 
 getCache ()
 Get the current Mustache Cache instance.
 
 getCharset ()
 Get the current Mustache character set.
 
 getCompiler ()
 Get the current Mustache Compiler instance.
 
 getEntityFlags ()
 Get the current Mustache entitity type to escape.
 
 getEscape ()
 Get the current Mustache escape callback.
 
 getHelper ($name)
 Get a Mustache helper by name.
 
 getHelpers ()
 Get the current set of Mustache helpers.
 
 getLoader ()
 Get the current Mustache template Loader instance.
 
 getLogger ()
 Get the current Mustache Logger instance.
 
 getParser ()
 Get the current Mustache Parser instance.
 
 getPartialsLoader ()
 Get the current Mustache partials Loader instance.
 
 getPragmas ()
 Get the current globally enabled pragmas.
 
 getTemplateClassName ($source)
 Helper method to generate a Mustache template class.
 
 getTokenizer ()
 Get the current Mustache Tokenizer instance.
 
 hasHelper ($name)
 Check whether this Mustache instance has a helper.
 
 loadLambda ($source, $delims=null)
 Load a Mustache lambda Template by source.
 
 loadPartial ($name)
 Load a Mustache partial Template by name.
 
 loadTemplate ($name)
 Load a Mustache Template by name.
 
 removeHelper ($name)
 Remove a helper by name.
 
 render ($template, $context=array())
 Shortcut 'render' invocation.
 
 setCache (Mustache_Cache $cache)
 Set the Mustache Cache instance.
 
 setCompiler (Mustache_Compiler $compiler)
 Set the Mustache Compiler instance.
 
 setHelpers ($helpers)
 Set an array of Mustache helpers.
 
 setLoader (Mustache_Loader $loader)
 Set the Mustache template Loader instance.
 
 setLogger ($logger=null)
 Set the Mustache Logger instance.
 
 setParser (Mustache_Parser $parser)
 Set the Mustache Parser instance.
 
 setPartials (array $partials=array())
 Set partials for the current partials Loader instance.
 
 setPartialsLoader (Mustache_Loader $partialsLoader)
 Set the Mustache partials Loader instance.
 
 setTokenizer (Mustache_Tokenizer $tokenizer)
 Set the Mustache Tokenizer instance.
 

Public Attributes

const PRAGMA_ANCHORED_DOT = 'ANCHORED-DOT'
 
const PRAGMA_BLOCKS = 'BLOCKS'
 
const PRAGMA_FILTERS = 'FILTERS'
 
const SPEC_VERSION = '1.2.2'
 
const VERSION = '2.14.2'
 

Protected Member Functions

 getLambdaCache ()
 Get the current Lambda Cache instance.
 

Detailed Description

Custom Moodle engine for mustache.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

core\output\mustache_engine::__construct ( array $options = [])

Mustache engine constructor.

This provides an additional option to the parent Mustache_Engine implementation: $options = [ // A list of helpers (by name) to prevent from executing within the rendering // of other helpers. 'disallowednestedhelpers' => ['js'] ];

Parameters
array$options[description]

Reimplemented from Mustache_Engine.

Member Function Documentation

◆ addHelper()

Mustache_Engine::addHelper ( $name,
$helper )
inherited

Add a new Mustache helper.

See also
Mustache_Engine\setHelpers
Parameters
string$name
mixed$helper

◆ getCache()

Mustache_Engine::getCache ( )
inherited

Get the current Mustache Cache instance.

If no Cache instance has been explicitly specified, this method will instantiate and return a new one.

Return values
Mustache_Cache

◆ getCharset()

Mustache_Engine::getCharset ( )
inherited

Get the current Mustache character set.

Return values
string

◆ getCompiler()

Mustache_Engine::getCompiler ( )
inherited

Get the current Mustache Compiler instance.

If no Compiler instance has been explicitly specified, this method will instantiate and return a new one.

Return values
Mustache_Compiler

◆ getEntityFlags()

Mustache_Engine::getEntityFlags ( )
inherited

Get the current Mustache entitity type to escape.

Return values
int

◆ getEscape()

Mustache_Engine::getEscape ( )
inherited

Get the current Mustache escape callback.

Return values
callable|null

◆ getHelper()

Mustache_Engine::getHelper ( $name)
inherited

Get a Mustache helper by name.

See also
Mustache_Engine\setHelpers
Parameters
string$name
Return values
mixedHelper

◆ getHelpers()

core\output\mustache_engine::getHelpers ( )

Get the current set of Mustache helpers.

See also
Mustache_Engine\setHelpers
Return values
Mustache_HelperCollection

Reimplemented from Mustache_Engine.

◆ getLambdaCache()

Mustache_Engine::getLambdaCache ( )
protectedinherited

Get the current Lambda Cache instance.

If 'cache_lambda_templates' is enabled, this is the default cache instance. Otherwise, it is a NoopCache.

See also
Mustache_Engine\getCache
Return values
Mustache_Cache

◆ getLoader()

Mustache_Engine::getLoader ( )
inherited

Get the current Mustache template Loader instance.

If no Loader instance has been explicitly specified, this method will instantiate and return a StringLoader instance.

Return values
Mustache_Loader

◆ getLogger()

Mustache_Engine::getLogger ( )
inherited

Get the current Mustache Logger instance.

Return values
Mustache_Logger|Psr\Log\LoggerInterface

◆ getParser()

Mustache_Engine::getParser ( )
inherited

Get the current Mustache Parser instance.

If no Parser instance has been explicitly specified, this method will instantiate and return a new one.

Return values
Mustache_Parser

◆ getPartialsLoader()

Mustache_Engine::getPartialsLoader ( )
inherited

Get the current Mustache partials Loader instance.

If no Loader instance has been explicitly specified, this method will instantiate and return an ArrayLoader instance.

Return values
Mustache_Loader

◆ getPragmas()

Mustache_Engine::getPragmas ( )
inherited

Get the current globally enabled pragmas.

Return values
array

◆ getTemplateClassName()

Mustache_Engine::getTemplateClassName ( $source)
inherited

Helper method to generate a Mustache template class.

This method must be updated any time options are added which make it so the same template could be parsed and compiled multiple different ways.

Parameters
string | Mustache_Source$source
Return values
stringMustache Template class name

◆ getTokenizer()

Mustache_Engine::getTokenizer ( )
inherited

Get the current Mustache Tokenizer instance.

If no Tokenizer instance has been explicitly specified, this method will instantiate and return a new one.

Return values
Mustache_Tokenizer

◆ hasHelper()

Mustache_Engine::hasHelper ( $name)
inherited

Check whether this Mustache instance has a helper.

See also
Mustache_Engine\setHelpers
Parameters
string$name
Return values
boolTrue if the helper is present

◆ loadLambda()

Mustache_Engine::loadLambda ( $source,
$delims = null )
inherited

Load a Mustache lambda Template by source.

This is a helper method used by Template instances to generate subtemplates for Lambda sections. You can most likely ignore it completely.

Parameters
string$source
string$delims(default: null)
Return values
Mustache_Template

◆ loadPartial()

Mustache_Engine::loadPartial ( $name)
inherited

Load a Mustache partial Template by name.

This is a helper method used internally by Template instances for loading partial templates. You can most likely ignore it completely.

Parameters
string$name
Return values
Mustache_Template

◆ loadTemplate()

Mustache_Engine::loadTemplate ( $name)
inherited

Load a Mustache Template by name.

Parameters
string$name
Return values
Mustache_Template

◆ removeHelper()

Mustache_Engine::removeHelper ( $name)
inherited

Remove a helper by name.

See also
Mustache_Engine\setHelpers
Parameters
string$name

◆ render()

Mustache_Engine::render ( $template,
$context = array() )
inherited

Shortcut 'render' invocation.

Equivalent to calling $mustache->loadTemplate($template)->render($context);

See also
Mustache_Engine\loadTemplate
Mustache_Template\render
Parameters
string$template
mixed$context(default: array())
Return values
stringRendered template

◆ setCache()

Mustache_Engine::setCache ( Mustache_Cache $cache)
inherited

Set the Mustache Cache instance.

Parameters
Mustache_Cache$cache

◆ setCompiler()

Mustache_Engine::setCompiler ( Mustache_Compiler $compiler)
inherited

Set the Mustache Compiler instance.

Parameters
Mustache_Compiler$compiler

◆ setHelpers()

Mustache_Engine::setHelpers ( $helpers)
inherited

Set an array of Mustache helpers.

An array of 'helpers'. Helpers can be global variables or objects, closures (e.g. for higher order sections), or any other valid Mustache context value. They will be prepended to the context stack, so they will be available in any template loaded by this Mustache instance.

Exceptions
Mustache_Exception_InvalidArgumentExceptionif $helpers is not an array or Traversable
Parameters
array | Traversable$helpers

◆ setLoader()

Mustache_Engine::setLoader ( Mustache_Loader $loader)
inherited

Set the Mustache template Loader instance.

Parameters
Mustache_Loader$loader

◆ setLogger()

Mustache_Engine::setLogger ( $logger = null)
inherited

Set the Mustache Logger instance.

Exceptions
Mustache_Exception_InvalidArgumentExceptionIf logger is not an instance of Mustache_Logger or Psr\Log\LoggerInterface
Parameters
Mustache_Logger | Psr\Log\LoggerInterface$logger

◆ setParser()

Mustache_Engine::setParser ( Mustache_Parser $parser)
inherited

Set the Mustache Parser instance.

Parameters
Mustache_Parser$parser

◆ setPartials()

Mustache_Engine::setPartials ( array $partials = array())
inherited

Set partials for the current partials Loader instance.

Exceptions
Mustache_Exception_RuntimeExceptionIf the current Loader instance is immutable
Parameters
array$partials(default: array())

◆ setPartialsLoader()

Mustache_Engine::setPartialsLoader ( Mustache_Loader $partialsLoader)
inherited

Set the Mustache partials Loader instance.

Parameters
Mustache_Loader$partialsLoader

◆ setTokenizer()

Mustache_Engine::setTokenizer ( Mustache_Tokenizer $tokenizer)
inherited

Set the Mustache Tokenizer instance.

Parameters
Mustache_Tokenizer$tokenizer

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