Add fragment processing. This will temporarily fix our PHP template inclusion woes.
[xhtml-compiler.git] / XHTMLCompiler / TextFilter / Fragment.php
blobdcf50de7d5fe69750a89e2af39c520097328b412
1 <?php
3 /**
4 * Converts documents that have the xc-fragment class on the body
5 * element into HTML fragments, which are only the contents of the
6 * body element
7 */
8 class XHTMLCompiler_TextFilter_Fragment extends XHTMLCompiler_TextFilter
11 var $name = 'Fragment';
13 public function process($text, $page, $manager) {
14 if (strpos($text, '<body class="xc-fragment">') === false) return $text;
15 preg_match('/<body class="xc-fragment">(.+?)<\/body>/s', $text, $matches);
16 file_put_contents($page->getPathStem() . '.frag', $matches[1]);
17 return $text;