Advertisement
vanchelo

Untitled

Jan 15th, 2014
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.46 KB | None | 0 0
  1. Blade::extend(function($content, $blade) {
  2.     $pattern = '/(?<!\w)(\s*)@link\(\s*(.*)\)/';
  3.  
  4.     preg_match_all($pattern, $content, $matches);
  5.  
  6.     $links = [
  7.         1 => 'hello.html',
  8.         2 => 'about.html',
  9.         3 => 'keks.html'
  10.     ];
  11.  
  12.     $replace = [];
  13.     foreach ($matches[0] as $k => $link)
  14.     {
  15.         $replace[$link] = isset($links[$matches[2][$k]]) ? $links[$matches[2][$k]] : '';
  16.     }
  17.  
  18.     return strtr($content, $replace);
  19. });
  20.  
  21. $view = View::make('test')->render();
  22.  
  23. echo $view;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement