Transphporm\Builder::output PHP Method

output() public method

public output ( $data = null, $document = false )
    public function output($data = null, $document = false)
    {
        $headers = [];
        $elementData = new \Transphporm\Hook\ElementData(new \SplObjectStorage(), $data);
        $data = new FunctionSet($elementData);
        $cachedOutput = $this->loadTemplate();
        //To be a valid XML document it must have a root element, automatically wrap it in <template> to ensure it does
        $template = new Template($this->isValidDoc($cachedOutput['body']) ? str_ireplace('<!doctype', '<!DOCTYPE', $cachedOutput['body']) : '<template>' . $cachedOutput['body'] . '</template>');
        $valueParser = new Parser\Value($data);
        $config = new Config($data, $valueParser, $elementData, new Hook\Formatter(), new Parser\CssToXpath($data, $template->getPrefix()), new FilePath($this->baseDir, $this->rootDir), $headers);
        foreach ($this->modules as $module) {
            $module->load($config);
        }
        $this->processRules($template, $config);
        $result = ['body' => $template->output($document), 'headers' => array_merge($cachedOutput['headers'], $headers)];
        $this->cache->write($this->template, $result);
        $result['body'] = $this->doPostProcessing($template)->output($document);
        return (object) $result;
    }

Usage Example

コード例 #1
0
    public function testOverrideBefore()
    {
        $xml = '<div>
			<span>Test</span>
		</div>';
        $includeFile = __DIR__ . DIRECTORY_SEPARATOR . 'include.xml';
        $tss = "div:before {content: 'foo' }\n\t\tdiv:before {content: 'bar';}\n\t\t";
        $template = new \Transphporm\Builder($xml, $tss);
        $this->assertEquals('<div>bar<span>Test</span></div>', $this->stripTabs($template->output()->body));
    }
All Usage Examples Of Transphporm\Builder::output