Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.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