Пример #1
0
 private function getShortcode()
 {
     $shortcode = new Shortcode();
     $shortcode->register('name', function (ShortcodeInterface $s) {
         return $s->getName();
     });
     $shortcode->register('content', function (ShortcodeInterface $s) {
         return $s->getContent();
     });
     $shortcode->register('nc', function (ShortcodeInterface $s) {
         return $s->getName() . ': ' . $s->getContent();
     });
     return $shortcode;
 }
Пример #2
0
 function testRegisterShortcodeUsingClasses()
 {
     $shortcode = new Shortcode();
     $shortcode->register('div', 'HTMLShortcode@div');
     $shortcode->register('img', 'HTMLShortcode@img');
     $exceptedDiv = '<div>Hello</div>';
     $exceptedImg = '<img src="#">';
     $this->assertEquals($exceptedDiv, $shortcode->compile('[div]Hello[/div]'));
     $this->assertEquals($exceptedImg, $shortcode->compile('[img src="#"]'));
 }
Пример #3
0
 /**
  * Render the current calld shortcode.
  *
  * @param array $matches
  * @return void 
  * @static 
  */
 public static function render($matches)
 {
     \Pingpong\Shortcode\Shortcode::render($matches);
 }