Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
Mustache_Context Class Reference

Public Member Functions

 __construct ($context=null)
 Mustache rendering Context constructor.
 
 find ($id)
 Find a variable in the Context stack.
 
 findAnchoredDot ($id)
 Find an 'anchored dot notation' variable in the Context stack.
 
 findDot ($id)
 Find a 'dot notation' variable in the Context stack.
 
 findInBlock ($id)
 Find an argument in the block context stack.
 
 last ()
 Get the last Context frame.
 
 pop ()
 Pop the last Context frame from the stack.
 
 popBlockContext ()
 Pop the last block Context frame from the stack.
 
 push ($value)
 Push a new Context frame onto the stack.
 
 pushBlockContext ($value)
 Push a new Context frame onto the block context stack.
 

Constructor & Destructor Documentation

◆ __construct()

Mustache_Context::__construct ( $context = null)

Mustache rendering Context constructor.

Parameters
mixed$contextDefault rendering context (default: null)

Member Function Documentation

◆ find()

Mustache_Context::find ( $id)

Find a variable in the Context stack.

Starting with the last Context frame (the context of the innermost section), and working back to the top-level rendering context, look for a variable with the given name:

  • If the Context frame is an associative array which contains the key $id, returns the value of that element.
  • If the Context frame is an object, this will check first for a public method, then a public property named $id. Failing both of these, it will try __isset and __get magic methods.
  • If a value named $id is not found in any Context frame, returns an empty string.
Parameters
string$idVariable name
Return values
mixedVariable value, or '' if not found

◆ findAnchoredDot()

Mustache_Context::findAnchoredDot ( $id)

Find an 'anchored dot notation' variable in the Context stack.

This is the same as findDot(), except it looks in the top of the context stack for the first value, rather than searching the whole context stack and starting from there.

See also
Mustache_Context\findDot
Exceptions
Mustache_Exception_InvalidArgumentExceptionif given an invalid anchored dot $id
Parameters
string$idDotted variable selector
Return values
mixedVariable value, or '' if not found

◆ findDot()

Mustache_Context::findDot ( $id)

Find a 'dot notation' variable in the Context stack.

Note that dot notation traversal bubbles through scope differently than the regular find method. After finding the initial chunk of the dotted name, each subsequent chunk is searched for only within the value of the previous result. For example, given the following context stack:

$data = array(
    'name' => 'Fred',
    'child' => array(
        'name' => 'Bob'
    ),
);

... and the Mustache following template:

{{ child.name }}

... the name value is only searched for within the child value of the global Context, not within parent Context frames.

Parameters
string$idDotted variable selector
Return values
mixedVariable value, or '' if not found

◆ findInBlock()

Mustache_Context::findInBlock ( $id)

Find an argument in the block context stack.

Parameters
string$id
Return values
mixedVariable value, or '' if not found

◆ last()

Mustache_Context::last ( )

Get the last Context frame.

Return values
mixedLast Context frame (object or array)

◆ pop()

Mustache_Context::pop ( )

Pop the last Context frame from the stack.

Return values
mixedLast Context frame (object or array)

◆ popBlockContext()

Mustache_Context::popBlockContext ( )

Pop the last block Context frame from the stack.

Return values
mixedLast block Context frame (object or array)

◆ push()

Mustache_Context::push ( $value)

Push a new Context frame onto the stack.

Parameters
mixed$valueObject or array to use for context

◆ pushBlockContext()

Mustache_Context::pushBlockContext ( $value)

Push a new Context frame onto the block context stack.

Parameters
mixed$valueObject or array to use for block context

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