Skip to content

Instantly share code, notes, and snippets.

@wpscholar
Created July 23, 2014 18:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpscholar/43ed8cf74b2624db9ca2 to your computer and use it in GitHub Desktop.
Save wpscholar/43ed8cf74b2624db9ca2 to your computer and use it in GitHub Desktop.
Load Ember templates in WordPress
<?php
/**
* Load Ember templates in WordPress
*/
public static function load_views() {
$iterator = new \DirectoryIterator( plugin_dir_path( __FILE__ ) . 'views' );
foreach ( $iterator as $file ) {
/**
* @var \SplFileInfo $file
*/
if ( $file->isFile() && 'html' == $file->getExtension() ) {
$template = $file->getBasename( '.html' );
echo '<script type="text/x-handlebars" data-template-name="' . esc_attr( $template ) . '">';
include( $file->getRealPath() );
echo '</script>' . PHP_EOL;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment