loader.php
48 lines
| 1 | <?php |
| 2 | namespace ElementsKit_Lite\Libs\Template; |
| 3 | |
| 4 | defined( 'ABSPATH' ) || exit; |
| 5 | |
| 6 | require 'transformer.php'; |
| 7 | |
| 8 | class Loader { |
| 9 | |
| 10 | private $transformer; |
| 11 | |
| 12 | function __construct() { |
| 13 | $this->transformer = new Transformer(); |
| 14 | } |
| 15 | |
| 16 | public function replace_tags( $string, $prefix, $force_lower = false ) { |
| 17 | return preg_replace_callback( |
| 18 | '/\\{\\{([^{}]+)\}\\}/', |
| 19 | function( $matches ) use ( $force_lower, $prefix ) { |
| 20 | |
| 21 | return $this->transformer->render( $matches[1], $prefix ); |
| 22 | }, |
| 23 | $string |
| 24 | ); |
| 25 | } |
| 26 | |
| 27 | private function tag_list() { |
| 28 | return array(); |
| 29 | } |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | /** |
| 35 | * Get the instance. |
| 36 | */ |
| 37 | private static $instance = null; |
| 38 | |
| 39 | public static function instance() { |
| 40 | if ( self::$instance == null ) { |
| 41 | self::$instance = new self(); |
| 42 | } |
| 43 | |
| 44 | return self::$instance; |
| 45 | } |
| 46 | |
| 47 | } |
| 48 |