当前位置: 首页>>代码示例>>PHP>>正文


PHP Mustache_Engine::getHelpers方法代码示例

本文整理汇总了PHP中Mustache_Engine::getHelpers方法的典型用法代码示例。如果您正苦于以下问题:PHP Mustache_Engine::getHelpers方法的具体用法?PHP Mustache_Engine::getHelpers怎么用?PHP Mustache_Engine::getHelpers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mustache_Engine的用法示例。


在下文中一共展示了Mustache_Engine::getHelpers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prepareContextStack

 /**
  * Helper method to prepare the Context stack.
  *
  * Adds the Mustache HelperCollection to the stack's top context frame if helpers are present.
  *
  * @param mixed $context Optional first context frame (default: null)
  *
  * @return Mustache_Context
  */
 protected function prepareContextStack($context = null)
 {
     $stack = new Mustache_Context();
     $helpers = $this->mustache->getHelpers();
     if (!$helpers->isEmpty()) {
         $stack->push($helpers);
     }
     if (!empty($context)) {
         $stack->push($context);
     }
     return $stack;
 }
开发者ID:educakanchay,项目名称:campus,代码行数:21,代码来源:Template.php

示例2: generateSlides


//.........这里部分代码省略.........
            } else {
                if ($type === 'gallery') {
                    require_once 'renderers/PostGalleryRenderer.php';
                } else {
                    if ($type === 'flickr' || $type === '500px') {
                        require_once 'renderers/CustomSourceRenderer.php';
                    } else {
                        if ($type === 'posts') {
                            require_once 'renderers/PostsListRenderer.php';
                        } else {
                            if ($type === 'nextgen') {
                                require_once 'renderers/NextGenRenderer.php';
                            } else {
                                if ($type === 'instagram') {
                                    require_once 'renderers/InstagramRenderer.php';
                                }
                            }
                        }
                    }
                }
            }
            if (is_array($slides) && count($slides) > 0) {
                $width = $gen_opts['width'];
                if (is_numeric($width)) {
                    $width .= 'px';
                }
                if ($width) {
                    $width = 'width:' . $width . ';';
                } else {
                    $width = '';
                }
                $height = $gen_opts['height'];
                if (is_numeric($height)) {
                    $height .= 'px';
                }
                if ($height) {
                    $height = 'height:' . $height . ';';
                } else {
                    $height = '';
                }
                $out .= '<div id="' . $css_id . '" class="royalSlider ' . $css_id . $skin . $template . '" style="' . $width . $height . ';">' . "\n";
                foreach ($slides as $key => $slide) {
                    if ($type === 'custom') {
                        $renderer = new NewRoyalSliderDefaultRenderer($slide, $gen_opts, $options);
                    } else {
                        if ($type === 'gallery') {
                            $renderer = new NewRoyalSliderPostGalleryRenderer($key, $slide, $gen_opts, $options);
                        } else {
                            if ($type === 'flickr' || $type === '500px') {
                                $renderer = new NewRoyalSliderCustomSourceRenderer($slide, $gen_opts, $options);
                            } else {
                                if ($type === 'posts') {
                                    $renderer = new NewRoyalSliderPostsRenderer($slide, $gen_opts, $options);
                                } else {
                                    if ($type === 'nextgen') {
                                        $renderer = new NewRoyalSliderNextGenRenderer($slide, $gen_opts, $options);
                                    } else {
                                        if ($type === 'instagram') {
                                            $renderer = new NewRoyalSliderInstagramRenderer($slide, $gen_opts, $options);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    $m->getHelpers()->clear();
                    apply_filters('new_rs_slides_renderer_helper', $m, $slide, $options);
                    $out .= $m->render($markup, $renderer) . "\n";
                }
                $out = apply_filters('new_rs_slides_output_before_end', $out, $id, $type);
                $out .= "\n" . '</div>' . "\n";
            } else {
                if ($type !== 'posts') {
                    $error_message = print_r($slides, true);
                    if (strlen($error_message) > 5) {
                        $out .= NewRoyalSliderMain::frontend_error(print_r($slides, true));
                    } else {
                        $out .= NewRoyalSliderMain::frontend_error(__('Slides are missing. ', 'new_royalslider') . print_r($slides, true));
                    }
                } else {
                    $out .= NewRoyalSliderMain::frontend_error(__('No posts found matching your criteria.', 'new_royalslider'));
                }
            }
            if (isset($curr_template) && isset($curr_template['wrapHTML'])) {
                $out .= $curr_template['wrapHTML']['after'];
            }
            if ($type != '500px' && $type != 'flickr' && $type != 'instagram') {
                $pattern = '\\[(\\[?)(gallery|new_royalslider)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)';
                preg_match_all('/' . $pattern . '/s', $out, $matches);
                $out = preg_replace_callback("/{$pattern}/s", array('NewRoyalSliderGenerator', 'strip_shortcode_tag'), $out);
                $out = do_shortcode($out);
            }
            $arr = array('out' => $out, 'js_init' => $js_init_code);
            if (!$disable_cache) {
                set_transient($transient_key, $arr, 60 * 60 * $refresh_hours);
            }
        }
        NewRoyalSliderMain::register_slider($id, $arr['js_init']);
        return $arr['out'];
    }
开发者ID:treydonovan,项目名称:mymexicotours,代码行数:101,代码来源:NewRoyalSliderGenerator.php

示例3: testHelpers

 public function testHelpers()
 {
     $foo = array($this, 'getFoo');
     $bar = 'BAR';
     $mustache = new Mustache_Engine(array('helpers' => array('foo' => $foo, 'bar' => $bar)));
     $helpers = $mustache->getHelpers();
     $this->assertTrue($mustache->hasHelper('foo'));
     $this->assertTrue($mustache->hasHelper('bar'));
     $this->assertTrue($helpers->has('foo'));
     $this->assertTrue($helpers->has('bar'));
     $this->assertSame($foo, $mustache->getHelper('foo'));
     $this->assertSame($bar, $mustache->getHelper('bar'));
     $mustache->removeHelper('bar');
     $this->assertFalse($mustache->hasHelper('bar'));
     $mustache->addHelper('bar', $bar);
     $this->assertSame($bar, $mustache->getHelper('bar'));
     $baz = array($this, 'wrapWithUnderscores');
     $this->assertFalse($mustache->hasHelper('baz'));
     $this->assertFalse($helpers->has('baz'));
     $mustache->addHelper('baz', $baz);
     $this->assertTrue($mustache->hasHelper('baz'));
     $this->assertTrue($helpers->has('baz'));
     // ... and a functional test
     $tpl = $mustache->loadTemplate('{{foo}} - {{bar}} - {{#baz}}qux{{/baz}}');
     $this->assertEquals('foo - BAR - __qux__', $tpl->render());
     $this->assertEquals('foo - BAR - __qux__', $tpl->render(array('qux' => "won't mess things up")));
 }
开发者ID:juanmndz,项目名称:build-podcast,代码行数:27,代码来源:EngineTest.php

示例4: generateSlides


//.........这里部分代码省略.........
                }
                $gen_opts = self::preParseOpts($options);
                if (isset($options['sopts'])) {
                    $o = array_merge($options, $options['sopts']);
                    $to_unset = array('sopts', 'posts', 'rs_500px', 'flickr');
                    foreach ($to_unset as $key => $value) {
                        if (isset($o[$value])) {
                            unset($o[$value]);
                        }
                    }
                    foreach ($o as $key => $option) {
                        if (is_array($option)) {
                            foreach ($option as $subkey => $suboption) {
                                if (is_numeric($suboption)) {
                                    $o[$key][$subkey] = (double) $suboption;
                                }
                            }
                        } else {
                            if (is_numeric($option)) {
                                $o[$key] = (double) $option;
                            }
                        }
                    }
                    //return;
                    $init_opts = json_encode($o);
                    $init_opts = str_replace(':"true"', ':!0', $init_opts);
                    $init_opts = str_replace(':"false"', ':!1', $init_opts);
                    $init_opts = str_replace('"', '\'', $init_opts);
                    $init_opts = str_replace(',\'', ',', $init_opts);
                    $init_opts = str_replace('\':', ':', $init_opts);
                    $init_opts = str_replace('{\'', '{', $init_opts);
                } else {
                    $init_opts = $options;
                }
            } else {
                $options = array();
                $gen_opts = self::preParseOpts(null);
                $init_opts = '';
            }
            $js_init_code = "\t\$('." . $css_id . "').royalSlider(" . $init_opts . ");\n" . $add_js;
            if (!isset($skin)) {
                $skin = 'rsDefault';
            }
            $skin = ' ' . $skin;
            $out = '';
            if ($gen_opts['thumb_width'] != 96 || $gen_opts['thumb_height'] != 72) {
                $out .= "\n<style type=\"text/css\">\n";
                $out .= '.' . $css_id . ' .rsThumbsVer { width:' . $gen_opts['thumb_width'] . 'px; } 
		.' . $css_id . ' .rsThumb { width: ' . $gen_opts['thumb_width'] . 'px; height: ' . $gen_opts['thumb_height'] . 'px; }';
                $out .= "\n</style>\n";
            }
            if (isset($curr_template) && isset($curr_template['wrapHTML'])) {
                $out .= str_replace('%width%', $gen_opts['width'], $curr_template['wrapHTML']['before']);
            }
            $options['id'] = $id;
            $slides = apply_filters('new_rs_slides_filter', $slides, $options, $type);
            if (is_array($slides)) {
                $out .= '<div id="' . $css_id . '" class="royalSlider ' . $css_id . $skin . $template . '" style="width:' . $gen_opts['width'] . '; height:' . $gen_opts['height'] . ';">';
                foreach ($slides as $key => $slide) {
                    if ($type === 'custom') {
                        $renderer = new NewRoyalSliderDefaultRenderer($slide, $gen_opts, $options);
                    } else {
                        if ($type === 'gallery') {
                            $renderer = new NewRoyalSliderPostGalleryRenderer($key, $slide, $gen_opts, $options);
                        } else {
                            if ($type === 'flickr' || $type === '500px') {
                                $renderer = new NewRoyalSliderCustomSourceRenderer($slide, $gen_opts, $options);
                            } else {
                                if ($type === 'posts') {
                                    $renderer = new NewRoyalSliderPostsRenderer($slide, $gen_opts, $options);
                                }
                            }
                        }
                    }
                    $m->getHelpers()->clear();
                    apply_filters('new_rs_slides_renderer_helper', $m, $slide, $options);
                    $out .= $m->render($markup, $renderer);
                }
                $out .= '</div>';
            } else {
                $out .= NewRoyalSliderMain::frontend_error(__('Slides are missing: ', 'new_royalslider') . print_r($slides, true));
            }
            if (isset($curr_template) && isset($curr_template['wrapHTML'])) {
                $out .= $curr_template['wrapHTML']['after'];
            }
            if ($type != '500px' && $type != 'flickr') {
                $pattern = '\\[(\\[?)(gallery|new_royalslider)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)';
                preg_match_all('/' . $pattern . '/s', $out, $matches);
                $out = preg_replace_callback("/{$pattern}/s", array('NewRoyalSliderGenerator', 'strip_shortcode_tag'), $out);
                $out = do_shortcode($out);
            }
            $arr = array('out' => $out, 'js_init' => $js_init_code);
            $refresh_hours = NewRoyalSliderMain::$refresh_hours;
            if ($refresh_hours > 0) {
                set_transient($transient_key, $arr, 60 * 60 * $refresh_hours);
            }
        }
        NewRoyalSliderMain::register_slider($id, $arr['js_init']);
        return $arr['out'];
    }
开发者ID:iplaydu,项目名称:Bob-Ellis-Shoes,代码行数:101,代码来源:NewRoyalSliderGenerator.php


注:本文中的Mustache_Engine::getHelpers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。