Created
July 23, 2014 18:47
-
-
Save wpscholar/43ed8cf74b2624db9ca2 to your computer and use it in GitHub Desktop.
Load Ember templates in WordPress
This file contains hidden or 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
<?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