Overview

Namespaces

  • Charcoal
    • View
      • Mustache
      • Php
      • Twig

Classes

  • Charcoal\View\AbstractEngine
  • Charcoal\View\AbstractLoader
  • Charcoal\View\AbstractView
  • Charcoal\View\GenericView
  • Charcoal\View\Mustache\AssetsHelpers
  • Charcoal\View\Mustache\MustacheEngine
  • Charcoal\View\Mustache\MustacheLoader
  • Charcoal\View\Mustache\TranslatorHelpers
  • Charcoal\View\Php\PhpEngine
  • Charcoal\View\Php\PhpLoader
  • Charcoal\View\Renderer
  • Charcoal\View\Twig\TwigEngine
  • Charcoal\View\Twig\TwigLoader
  • Charcoal\View\ViewConfig
  • Charcoal\View\ViewServiceProvider

Interfaces

  • Charcoal\View\EngineInterface
  • Charcoal\View\LoaderInterface
  • Charcoal\View\Mustache\HelpersInterface
  • Charcoal\View\ViewableInterface
  • Charcoal\View\ViewInterface

Traits

  • Charcoal\View\ViewableTrait
  • Overview
  • Namespace
  • Class
 1: <?php
 2: 
 3: namespace Charcoal\View\Php;
 4: 
 5: // Intra-module (`charcoal-view`) depentencies
 6: use \Charcoal\View\AbstractEngine;
 7: 
 8: /**
 9:  *
10:  */
11: class PhpEngine extends AbstractEngine
12: {
13:     /**
14:      * @return string
15:      */
16:     public function type()
17:     {
18:         return 'php';
19:     }
20: 
21:     /**
22:      * @param string $templateString The template string to render.
23:      * @param mixed  $context        The rendering context.
24:      * @return string The rendered template string.
25:      */
26:     public function renderTemplate($templateString, $context)
27:     {
28:         // Prevents leaking global variable by forcing anonymous scope
29:         $render = function($templateString, $context) {
30:             extract($context);
31:             return eval('?>'.$templateString);
32:         };
33: 
34:         ob_start();
35:         $render($templateString, $context);
36:         $output = ob_get_clean();
37: 
38:         return $output;
39:     }
40: }
41: 
API documentation generated by ApiGen