<commit_before><?php
namespace AmidaMVC\Tools;

/**
 * really dumb and simple template by PHP
 */

class Template
{
    static $ext_php  = array( 'php' );
    static $ext_html = array( 'html', 'html' );
    static $ext_md   = array( 'md', 'markdown' );
    static $ext_text = array( 'text', 'txt' );
    // +-------------------------------------------------------------+
    function inject( $template, $_data ) {
        extract( $_data );
        include( $template );
    }
    // +-------------------------------------------------------------+
    function convertContents( $data ) {
        $content_type = $data[ 'content_type' ];
        if( !$content_type ) {
            $content_type = pathinfo( $data[ 'file_name' ], PATHINFO_EXTENSION );
        }
        if( in_array( $content_type, static::$ext_php ) ) {
            self::loadPhpAsCode( $data );
        }
        else if( in_array( $content_type, static::$ext_html ) ) {
            self::loadHtml( $data );
        }
        else if( in_array( $content_type, static::$ext_text ) ) {
            self::loadText( $data );
        }
        else if( in_array( $content_type, static::$ext_md ) ) {
            self::loadMarkdown( $data );
        }
        return $data;
    }
    // +-------------------------------------------------------------+
    function loadPhpAsCode( &$data ) {
        $content = $data[ 'contents' ];
        $content = highlight_string( $content, TRUE );
        $data[ 'contents' ] = $content;
        if( !$data[ 'title' ] ) {
            $title   = pathinfo( $data[ 'file_name' ], PATHINFO_BASENAME );
            $data[ 'title' ] = $title;
        }
    }
    // +-------------------------------------------------------------+
    function loadText( &$data ) {
        $content = $data[ 'contents' ];
        $content = nl2br( $content );
        $data[ 'contents' ] = $content;
        if( !$data[ 'title' ] ) {
            $title   = pathinfo( $data[ 'file_name' ], PATHINFO_BASENAME );
            $data[ 'title' ] = $title;
        }
    }<commit_msg>shows text inside <pre> tag.<commit_after><?php
namespace AmidaMVC\Tools;

/**
 * really dumb and simple template by PHP
 */

class Template
{
    static $ext_php  = array( 'php' );
    static $ext_html = array( 'html', 'html' );
    static $ext_md   = array( 'md', 'markdown' );
    static $ext_text = array( 'text', 'txt' );
    // +-------------------------------------------------------------+
    function inject( $template, $_data ) {
        extract( $_data );
        include( $template );
    }
    // +-------------------------------------------------------------+
    function convertContents( $data ) {
        $content_type = $data[ 'content_type' ];
        if( !$content_type ) {
            $content_type = pathinfo( $data[ 'file_name' ], PATHINFO_EXTENSION );
        }
        if( in_array( $content_type, static::$ext_php ) ) {
            self::loadPhpAsCode( $data );
        }
        else if( in_array( $content_type, static::$ext_html ) ) {
            self::loadHtml( $data );
        }
        else if( in_array( $content_type, static::$ext_text ) ) {
            self::loadText( $data );
        }
        else if( in_array( $content_type, static::$ext_md ) ) {
            self::loadMarkdown( $data );
        }
        return $data;
    }
    // +-------------------------------------------------------------+
    function loadPhpAsCode( &$data ) {
        $content = $data[ 'contents' ];
        $content = highlight_string( $content, TRUE );
        $data[ 'contents' ] = $content;
        if( !$data[ 'title' ] ) {
            $title   = pathinfo( $data[ 'file_name' ], PATHINFO_BASENAME );
            $data[ 'title' ] = $title;
        }
    }
    // +-------------------------------------------------------------+
    function loadText( &$data ) {
        $content = '<pre>'. $data[ 'contents' ] . '</pre>';
        $data[ 'contents' ] = $content;
        if( !$data[ 'title' ] ) {
            $title   = pathinfo( $data[ 'file_name' ], PATHINFO_BASENAME );
            $data[ 'title' ] = $title;
        }
    }
{'fraction_non_alphanumeric': 0.2660483280449109, 'fraction_numerical': 0.000244081034903588, 'mean_word_length': 1.4148497348261637, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1055914', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1191, 'n_words': 259}