mirrored from git://develop.git.wordpress.org/
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
Copy pathclass-wp-html-template.php
48 lines (44 loc) · 1.23 KB
/
class-wp-html-template.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
declare( strict_types=1 );
class WP_HTML_Template {
/**
* HTML Template indicating where to mix a static HTML template
* and placeholders for dynamic values.
*
* @var string
*/
public $template;
/**
* Stores data necessary to render a template, if any required.
*
* @var array|null
*/
public $data;
/**
* Constructor function.
*
* Example:
*
* // No placeholders are required, only a template string.
* new WP_HTML_Template( '<p>Hello, World!</p>' );
*
* // Placeholders for simple substitution.
* new WP_HTML_Template( '<p>Hello, </%name>!</p>', array( 'name' => $name ) );
*
* // Spread-operator for sets of attributes.
* new WP_HTML_Template(
* '<button ...interactivity_args>Click me!</button>',
* array(
* 'data-wp-text="context.buttonLabel"',
* 'data-wp-click="actions.clickButton",
* )
* );
*
* @param string $template Static HTML template, possibly including placeholders.
* @param array|null $data Optional. Data provided for placeholders, if any.
*/
public function __construct( string $template, array $data = null ) {
$this->template = $template;
$this->data = $data;
}
}