PHP Classes

File: examples/tags/syntax/tag.php

Recommend this page to a friend!
  Classes of Oliver Lillie  >  PHP Custom Tags  >  examples/tags/syntax/tag.php  >  Download  
File: examples/tags/syntax/tag.php
Role: Auxiliary script
Content type: text/plain
Description: Example script
Class: PHP Custom Tags
Template engine based on tags similar to HTML
Author: By
Last change: Update of examples/tags/syntax/tag.php
Date: 10 months ago
Size: 1,581 bytes


Class file image Download

namespace CustomTags;

ct_syntax($tags, $source)
// add the required scripts
static $geshi_required;
$geshi_required = true;
// loop through all the tags and capture the block source and the
// replacement value so they can be bulk replaced
$replacements = array();
        foreach (
$tags as $tag)
$language = isset($tag['attributes']['lang']) ? $tag['attributes']['lang'] : 'php';
$use_lines = isset($tag['attributes']['lines']) ? $tag['attributes']['lines'] === 'true' : false;
$content = isset($tag['attributes']['src']) ? file_get_contents($tag['attributes']['src']) : $tag['content'];
$geshi = new GeSHi(trim($content), $language);
// $geshi->set_header_type(GESHI_HEADER_PRE);
if($use_lines === true)
$geshi->set_line_style('background: #fcfcfc;', 'background: #f0f0f0;');
$code = $geshi->parse_code();
$code .= '<span style="font-size:10px;"><a href="" title="GeSHi - Generic Syntax Highlighter :: Home" style="color:#898989;">Geshi syntax highlighter</a></span><br />';
$replacements[$tag['tag']] = $code;
strtr($source, $replacements);
// this signals that the tag should be processed as a collection, meaning
// that the argument supplied to the function is an array of tags and not
// a single tag. The collected tags will be processed at the end of the parse.
$collect = true;

For more information send a message to info at phpclasses dot org.