Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

(no description)

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

Defines 1 class

Mustache_Parser:: (8 methods):
  parse()
  setPragmas()
  buildTree()
  clearStandaloneLines()
  tokenIsWhitespace()
  checkIfTokenIsAllowedInParent()
  getNameAndFilters()
  enablePragma()


Class: Mustache_Parser  - X-Ref

Mustache Parser class.

This class is responsible for turning a set of Mustache tokens into a parse tree.
parse(array $tokens = array()   X-Ref
Process an array of Mustache tokens and convert them into a parse tree.

param: array $tokens Set of Mustache tokens
return: array Mustache token parse tree

setPragmas(array $pragmas)   X-Ref
Enable pragmas across all templates, regardless of the presence of pragma
tags in the individual templates.

param: string[] $pragmas

buildTree(array &$tokens, array $parent = null)   X-Ref
Helper method for recursively building a parse tree.

param: array &$tokens Set of Mustache tokens
param: array $parent  Parent token (default: null)
return: array Mustache Token parse tree

clearStandaloneLines(array &$nodes, array &$tokens)   X-Ref
Clear standalone line tokens.

Returns a whitespace token for indenting partials, if applicable.

param: array $nodes  Parsed nodes
param: array $tokens Tokens to be parsed
return: array|null Resulting indent token, if any

tokenIsWhitespace(array $token)   X-Ref
Check whether token is a whitespace token.

True if token type is T_TEXT and value is all whitespace characters.

param: array $token
return: bool True if token is a whitespace token

checkIfTokenIsAllowedInParent($parent, array $token)   X-Ref
Check whether a token is allowed inside a parent tag.

param: array|null $parent
param: array      $token

getNameAndFilters($name)   X-Ref
Split a tag name into name and filters.

param: string $name
return: array [Tag name, Array of filters]

enablePragma($name)   X-Ref
Enable a pragma.

param: string $name