Skip to content

Instantly share code, notes, and snippets.

@westonruter
Created August 14, 2014 04:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westonruter/e23856c7dec7d8aedf9c to your computer and use it in GitHub Desktop.
Save westonruter/e23856c7dec7d8aedf9c to your computer and use it in GitHub Desktop.
<?php
$data = array();
/* ... */
$tpl_vars = array();
foreach ( $data as $key => $value ) {
$tpl_vars[ '{{' . $key . '}}' ] = esc_attr( $value );
}
$html = str_replace(
array_keys( $tpl_vars ),
array_values( $tpl_vars ),
$tpl
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment