WP_CLI\Utils

mustache_render()WP-CLI 1.0

Render PHP or other types of files using Mustache templates.

IMPORTANT: Automatic HTML escaping is disabled!

No Hooks.

Return

null. Nothing.

Usage

mustache_render( $template_name, $data );
$template_name (required)
-
$data **
-
Default: []

mustache_render() code WP-CLI 2.7.0-alpha

function mustache_render( $template_name, $data = [] ) {
	if ( ! file_exists( $template_name ) ) {
		$template_name = WP_CLI_ROOT . "/templates/$template_name";
	}

	$template = file_get_contents( $template_name );

	$mustache = new Mustache_Engine(
		[
			'escape' => function ( $val ) {
				return $val; },
		]
	);

	return $mustache->render( $template, $data );
}