Sha256: 29a6ffefd0d0dd7131e169e1332e9d85486b4e3613ed7aa9979563ea01f1d568

Contents?: true

Size: 908 Bytes

Versions: 10

Compression:

Stored size: 908 Bytes

Contents

<?php

namespace MtHaml\Filter;

use MtHaml\NodeVisitor\RendererAbstract as Renderer;
use MtHaml\NodeVisitor\PhpRenderer;
use MtHaml\Node\Filter;

class Php extends AbstractFilter
{
    public function isOptimizable(Renderer $renderer, Filter $node, $options)
    {
        if (!$renderer instanceof PhpRenderer) {
            return false;
        }

        return parent::isOptimizable($renderer, $node, $options);
    }

    public function optimize(Renderer $renderer, Filter $node, $options)
    {
        $renderer->write('<?php')->indent();
        $this->renderFilter($renderer, $node);
        $renderer->undent()->write('?>');
    }

    public function filter($content, array $context, $options)
    {
        $__content__ = '?><?php '.$content;
        unset($options, $content);
        extract($context);
        ob_start();
        eval($__content__);

        return ob_get_clean();
    }
}

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
guard-mthaml-0.4.0 vendor/mthaml/mthaml/lib/MtHaml/Filter/Php.php
guard-mthaml-0.3.1 vendor/mthaml/mthaml/lib/MtHaml/Filter/Php.php
guard-mthaml-0.3.0 vendor/mthaml/mthaml/lib/MtHaml/Filter/Php.php
guard-mthaml-0.2.5 vendor/mthaml/mthaml/lib/MtHaml/Filter/Php.php
guard-mthaml-0.2.4 vendor/mthaml/mthaml/lib/MtHaml/Filter/Php.php
guard-mthaml-0.2.3 vendor/mthaml/mthaml/lib/MtHaml/Filter/Php.php
guard-mthaml-0.2.2 vendor/mthaml/mthaml/lib/MtHaml/Filter/Php.php
guard-mthaml-0.2.1 vendor/mthaml/mthaml/lib/MtHaml/Filter/Php.php
guard-mthaml-0.2.0 vendor/mthaml/mthaml/lib/MtHaml/Filter/Php.php
guard-mthaml-0.1.0 vendor/mthaml/mthaml/lib/MtHaml/Filter/Php.php