mirrored from git://develop.git.wordpress.org/
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explore different ways of providing Bit renderers.
- Loading branch information
Showing
3 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters