Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

(no description)

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

Defines 1 class

Mustache_Context:: (11 methods):
  __construct()
  push()
  pushBlockContext()
  pop()
  popBlockContext()
  last()
  find()
  findDot()
  findAnchoredDot()
  findInBlock()
  findVariableInStack()


Class: Mustache_Context  - X-Ref

Mustache Template rendering Context.

__construct($context = null)   X-Ref
Mustache rendering Context constructor.

param: mixed $context Default rendering context (default: null)

push($value)   X-Ref
Push a new Context frame onto the stack.

param: mixed $value Object or array to use for context

pushBlockContext($value)   X-Ref
Push a new Context frame onto the block context stack.

param: mixed $value Object or array to use for block context

pop()   X-Ref
Pop the last Context frame from the stack.

return: mixed Last Context frame (object or array)

popBlockContext()   X-Ref
Pop the last block Context frame from the stack.

return: mixed Last block Context frame (object or array)

last()   X-Ref
Get the last Context frame.

return: mixed Last Context frame (object or array)

find($id)   X-Ref
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.

param: string $id Variable name
return: mixed Variable value, or '' if not found

findDot($id)   X-Ref
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.

param: string $id Dotted variable selector
return: mixed Variable value, or '' if not found

findAnchoredDot($id)   X-Ref
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.

param: string $id Dotted variable selector
return: mixed Variable value, or '' if not found

findInBlock($id)   X-Ref
Find an argument in the block context stack.

param: string $id
return: mixed Variable value, or '' if not found

findVariableInStack($id, array $stack)   X-Ref
Helper function to find a variable in the Context stack.

param: string $id    Variable name
param: array  $stack Context stack
return: mixed Variable value, or '' if not found