示例#1
0
 public function testLoadPartialCascading()
 {
     $loader = new Mustache_Loader_ArrayLoader(array('foo' => 'FOO'));
     $mustache = new Mustache_Engine(array('loader' => $loader));
     $tpl = $mustache->loadTemplate('foo');
     $this->assertSame($tpl, $mustache->loadPartial('foo'));
     $mustache->setPartials(array('foo' => 'f00'));
     // setting partials overrides the default template loading fallback.
     $this->assertNotSame($tpl, $mustache->loadPartial('foo'));
     // but it didn't overwrite the original template loader templates.
     $this->assertSame($tpl, $mustache->loadTemplate('foo'));
 }
示例#2
0
 /**
  * Loads the Mustache template or partial for the active theme.
  *
  * @param  array  $theme    Meta headers for the active theme
  * @param  array  $settings Gallery shortcode settings
  * @return void
  */
 protected function _load_theme_template($theme, $settings)
 {
     $loaders = array_merge(self::_load_theme_template_override($theme['plugin_override_path']), array(new Mustache_Loader_FilesystemLoader($theme['plugin_path'])));
     $partial_loaders = array_merge(self::_load_theme_template_override($theme['partials_override_path']), array(new Mustache_Loader_FilesystemLoader($theme['partials_path'])));
     $mustache = new Mustache_Engine(array('loader' => new Mustache_Loader_CascadingLoader($loaders), 'partials_loader' => new Mustache_Loader_CascadingLoader($partial_loaders)));
     $this->_template = isset($settings['partial']) ? $mustache->loadPartial(strtolower($settings['partial'])) : $mustache->loadTemplate(strtolower($theme['name']));
     // Backwards-Compatibility for Vimeography Pro < 0.7
     $this->_theme = $this->_template;
 }