public function AsHTML($useGFM=false) {
        if($this->parsedHTML!==false) {
            return $this->parsedHTML;
        }
        
        //Setup renderer
        $renderer=$this->getRenderer();
        $supported=$renderer->isSupported();
        if($supported!==true) {
            $class_name=get_class($renderer);
            user_error("Renderer $class_name is not supported on this system: $supported");
        }
        
        if($renderer instanceof GithubMarkdownRenderer) {
            $beforeUseGFM=GithubMarkdownRenderer::getUseGFM();
            
            GithubMarkdownRenderer::setUseGFM($useGFM);
        }
        
        //Init cache stuff
        $cacheKey=md5('Markdown_'.$this->tableName.'_'.$this->name.':'.$this->value);
        $cache=SS_Cache::factory('Markdown');
        $cachedHTML=$cache->load($cacheKey);
        
        //Check cache, if it's good use it instead
        if($cachedHTML!==false) {
            $this->parsedHTML=$cachedHTML;
            return $this->parsedHTML;
        }      
        
        //If empty save time by not attempting to render
        if(empty($this->value)) {
            return $this->value;
        }
        
        //Get rendered HTML
        $response=$renderer->getRenderedHTML($this->value);
        
        //Store response in memory
        $this->parsedHTML=$response;
        
        //Cache response to file system
        $cache->save($this->parsedHTML, $cacheKey);
        
        //Reset GFM
        if($renderer instanceof GithubMarkdownRenderer) {
            GithubMarkdownRenderer::setUseGFM($beforeUseGFM);
        }
                
        //Return response
        return $this->parsedHTML;
    }
public function AsHTML($useGFM=false) {
        if($this->parsedHTML!==false) {
            return $this->parsedHTML;
        }
        
        //Setup renderer
        $renderer=$this->getRenderer();
        $supported=$renderer->isSupported();
        if($supported!==true) {
            $class_name=get_class($renderer);
            user_error("Renderer $class_name is not supported on this system: $supported");
        }
        
        if($renderer instanceof GithubMarkdownRenderer) {
            $beforeUseGFM=GithubMarkdownRenderer::getUseGFM();
            
            GithubMarkdownRenderer::setUseGFM($useGFM);
        }
        
        //Init cache stuff
        $cacheKey=md5('Markdown_'.$this->tableName.'_'.$this->name.':'.$this->value);
        $cache=SS_Cache::factory('Markdown');
        $cachedHTML=$cache->load($cacheKey);
        
        //Check cache, if it's good use it instead
        if($cachedHTML!==false) {
            $this->parsedHTML=$cachedHTML;
            return $this->parsedHTML;
        }      
        
        //If empty save time by not attempting to render
        if(empty($this->value)) {
            return $this->value;
        }
        
        //Get rendered HTML
        $response=$renderer->getRenderedHTML($this->value);
        
        //Store response in memory
        $this->parsedHTML=$response;
        
        //Cache response to file system
        $cache->save($this->parsedHTML, $cacheKey);
        
        //Reset GFM
        if($renderer instanceof GithubMarkdownRenderer) {
            GithubMarkdownRenderer::setUseGFM($beforeUseGFM);
        }
                
        //Return response
        return $this->parsedHTML;
    }
public function AsHTML ( $ useGFM = false ) { if ( $ this -> parsedHTML !== false ) { return $ this -> parsedHTML ; } //Setup renderer $ renderer = $ this -> getRenderer ( ) ; $ supported = $ renderer -> isSupported ( ) ; if ( $ supported !== true ) { $ class_name = get_class ( $ renderer ) ; user_error ( "Renderer $class_name is not supported on this system: $supported" ) ; } if ( $ renderer instanceof GithubMarkdownRenderer ) { $ beforeUseGFM = GithubMarkdownRenderer :: getUseGFM ( ) ; GithubMarkdownRenderer :: setUseGFM ( $ useGFM ) ; } //Init cache stuff $ cacheKey = md5 ( 'Markdown_' . $ this -> tableName . '_' . $ this -> name . ':' . $ this -> value ) ; $ cache = SS_Cache :: factory ( 'Markdown' ) ; $ cachedHTML = $ cache -> load ( $ cacheKey ) ; //Check cache, if it's good use it instead if ( $ cachedHTML !== false ) { $ this -> parsedHTML = $ cachedHTML ; return $ this -> parsedHTML ; } //If empty save time by not attempting to render if ( empty ( $ this -> value ) ) { return $ this -> value ; } //Get rendered HTML $ response = $ renderer -> getRenderedHTML ( $ this -> value ) ; //Store response in memory $ this -> parsedHTML = $ response ; //Cache response to file system $ cache -> save ( $ this -> parsedHTML , $ cacheKey ) ; //Reset GFM if ( $ renderer instanceof GithubMarkdownRenderer ) { GithubMarkdownRenderer :: setUseGFM ( $ beforeUseGFM ) ; } //Return response return $ this -> parsedHTML ; }
Checks cache to see if the contents of this field have already been loaded from github, if they haven't then a request is made to the github api to render the markdown
@param {bool} $useGFM Use Github Flavored Markdown or render using plain markdown defaults to false just like how readme files are rendered on github
@return {string} Markdown rendered as HTML
Checks cache to see if the contents of this field have already been loaded from github if they haven t then a request is made to the github api to render the markdown