Generate the source for a PHP class that renders an intermediate representation according to
given rendering configuration

@param  Rendering $rendering
@return string
356593
public function generate(Rendering $rendering)
	{
		// Compile the templates to PHP
		$compiledTemplates = array_map([$this, 'compileTemplate'], $rendering->getTemplates());

		// Start the code right after the class name, we'll prepend the header when we're done
		$php = [];
		$php[] = ' extends \\s9e\\TextFormatter\\Renderers\\PHP';
		$php[] = '{';
		$php[] = '	protected $params=' . self::export($rendering->getAllParameters()) . ';';
		$php[] = '	protected function renderNode(\\DOMNode $node)';
		$php[] = '	{';
		$php[] = '		' . SwitchStatement::generate('$node->nodeName', $compiledTemplates, '$this->at($node);');
		$php[] = '	}';

		// Append the Quick renderer if applicable
		if ($this->enableQuickRenderer)
		{
			$php[] = Quick::getSource($compiledTemplates);
		}

		// Close the class definition
		$php[] = '}';

		// Assemble the source
		$php = implode("\n", $php);

		// Finally, optimize the control structures
		if (isset($this->controlStructuresOptimizer))
		{
			$php = $this->controlStructuresOptimizer->optimize($php);
		}

		// Generate a name for that class if necessary, and save it
		$className = (isset($this->className))
		           ? $this->className
		           : $this->defaultClassPrefix . sha1($php);
		$this->lastClassName = $className;

		// Prepare the header
		$header = "\n"
		        . "/**\n"
		        . "* @package   s9e\TextFormatter\n"
		        . "* @copyright Copyright (c) 2010-2019 The s9e Authors\n"
		        . "* @license   http://www.opensource.org/licenses/mit-license.php The MIT License\n"
		        . "*/\n";

		// Declare the namespace and class name
		$pos = strrpos($className, '\\');
		if ($pos !== false)
		{
			$header .= 'namespace ' . substr($className, 0, $pos) . ";\n\n";
			$className = substr($className, 1 + $pos);
		}

		// Prepend the header and the class name
		$php = $header . 'class ' . $className . $php;

		return $php;
	}
757031
public function render(int $indentLevel = 0): string
    {
        $result = '';

        if (!$this->docComment->isEmpty()) {
            $result .= $this->docComment->render($indentLevel) . "\n";
        }

        //Class header
        $header = "class {$this->getName()}";

        //Rendering extends
        if (!empty($this->extends)) {
            $header .= " extends {$this->extends}";
        }

        if (!empty($this->interfaces)) {
            $interfaces = join(", ", array_keys($this->interfaces));
            $header .= " implements {$interfaces}";
        }

        $result .= $this->addIndent($header, $indentLevel) . "\n";
        $result .= $this->addIndent("{", $indentLevel) . "\n";

        //Rendering class body
        $result .= $this->renderBody($indentLevel);

        $result = rtrim($result, "\n") . "\n";
        $result .= $this->addIndent("}", $indentLevel);

        return $result;
    }
1178918
public function render($key, RendererInterface $renderer = null)
	{
		if (!$this->hasMenu($key)) {
			return '';
		}

		return $this->renderMenu($this->getMenu($key), $renderer);
	}
1276097
public function render($part = 'content')
    {
        $return = '';
        switch ($part) {
            case 'content':
                $return = $this->renderContent();
                break;
            case 'filter':
                $return = $this->renderFilter();
                break;
            case 'summary':
                $return = $this->renderSummary();
                break;
            case 'header':
                $return = $this->renderHeader();
                break;
        }

        return $return;
    }
221883
def pre_render
      @attr = @source.attr
      cp = get_color($datacolor, @source.color(), @source.bgcolor())
      @color_pair = @source.color_pair || cp
      @cp = FFI::NCurses.COLOR_PAIR(cp)
    end
894834
public function render($html = null) {
		if ($this->_tagCached === null) {
			$tag = '<' . $this->_tag;
			
			// Classes
			if (! empty($this->_classes)) {
				$this->setAttr(
					self::ATTR_CLASS,
					implode(' ', $this->_classes)
				);
			}

			// Style
			if (! empty($this->_style)) {
				$style = [];
				
				foreach ($this->_style as $param => $value) {
					$style[] = $param . ':' . $value . ';';
				}
				
				$this->setAttr(
					self::ATTR_STYLE,
					implode(' ', $style)
				);
			}

			// Attrs
			if (! empty($this->_attrs)) {
				$attrs = [];
				
				foreach ($this->_attrs as $attr => $value) {
					$attrs[] = $attr . '="' . $value . '"';
				}

				$tag .= ' ' .  implode(' ', $attrs);
			}
			
			$tag .= $this->_closed ? ' />' : '>';
			
			$this->_tagCached = $tag;
		}
		
		if ($this->_closed) {
			return $this->_tagCached;
		}
			
		return $this->_tagCached . ($html === null ? $this->_html : $html) . '</' . $this->_tag . '>';
	}
967755
public function render(ResultsRenderer $renderer)
    {
        $results = array_filter($this->result->getResults(), function (ResultInterface $result) {
            return $result instanceof FailureInterface;
        });

        $output = '';
        if (count($results)) {
            $output .= $renderer->center("Some requests to your solution produced incorrect output!\n");
        }

        foreach ($results as $key => $request) {
            $output .= $renderer->lineBreak();
            $output .= "\n";
            $output .= $renderer->style(sprintf('Request %d', $key + 1), ['bold', 'underline', 'blue']);
            $output .= ' ' . $renderer->style(' FAILED ', ['bg_red', 'bold']) . "\n\n";
            $output .= "Request Details:\n\n";
            $output .= $this->requestRenderer->renderRequest($request->getRequest()) . "\n";

            $output .= $renderer->renderResult($request) . "\n";
        }

        return $output;
    }
780366
public function getRenderer()
    {
        $collectorClass = get_class($this);
        $rendererClass = '\\' . str_replace('Collectors', 'Renderer\\Html', $collectorClass);

        if (!class_exists($rendererClass)) {
            throw new \RuntimeException('Collector ' . $collectorClass . ' is renderable but ' . $rendererClass . ' does not exist');
        }

        return new $rendererClass;
    }
209834
public function render(): string
    {
        $output = '';

        if ($this->token === null) {
            $output .= $this->counter . ". ";
        } else {
            $output .= $this->token;
        }

        if ($this->hasChildren() === true) {
            foreach ($this->children() as $child) {
                $output .= $child->render();
            }
        }

        $output .= $this->escape($this->insert);

        return $output;
    }
1097600
public function render(RendererInterface $renderer = null)
    {
        if ($renderer) {
            return $renderer->render($this);
        }

        return '<td' . $this->attributes->render() . '>' . $this->content . '</td>';
    }
378291
private function buildRenderer($render = 'foil', array $renderingInfo = []) {
      switch($render) {
        case "raw":
          $renderer = new RawRenderer();
          $renderInfo = [];
          break;
        
        case "json":
          $renderer = new JsonRenderer();
          $renderInfo = [];
          break;
        
        case "foil":
        default:
          $renderer = new FoilRenderer();
          $renderInfo['options'] = $renderingInfo['engines']['foil']['options'];
          $renderInfo['folders'] = $renderingInfo['engines']['foil']['folders'];
          break;
      }

      //Setup renderer
      $renderer->setup($renderInfo);
      
      return $renderer;
    }
149237
public function toJson($render = false)
        {
            $json = json_encode($this->toArray(true, true));

            if (false === $render) {
                return $json;
            } else {
                header('content-type: application/json; charset=utf-8');
                die($json);
            }
        }
137218
public function render($renderer)
    {
        // Set up the style
        if ($renderer->getCurrentStyle() != $this->styleName) {
            $renderer->setCurrentStyle($this->styleName);
        }
        $temptext = str_replace('#PAGENUM#', (string) $renderer->PageNo(), $this->text);
        // underline «title» part of Source item
        $temptext = str_replace([
            '«',
            '»',
        ], [
            '<u>',
            '</u>',
        ], $temptext);

        // Paint the text color or they might use inherited colors by the previous function
        $match = [];
        if (preg_match('/#?(..)(..)(..)/', $this->color, $match)) {
            $r = hexdec($match[1]);
            $g = hexdec($match[2]);
            $b = hexdec($match[3]);
            $renderer->SetTextColor($r, $g, $b);
        } else {
            $renderer->SetTextColor(0, 0, 0);
        }
        $temptext = FunctionsRtl::spanLtrRtl($temptext);
        $temptext = str_replace(
            [
                '<br><span dir="rtl">',
                '<br><span dir="ltr">',
                '> ',
                ' <',
            ],
            [
                '<span dir="rtl" ><br>',
                '<span dir="ltr" ><br>',
                '>&nbsp;',
                '&nbsp;<',
            ],
            $temptext
        );
        $renderer->writeHTML(
            $temptext,
            false,
            false,
            true,
            false,
            ''
        ); //change height - line break etc. - the form is mirror on rtl pages
        // Reset the text color to black or it will be inherited
        $renderer->SetTextColor(0, 0, 0);
    }
447568
public function generate()
    {
        $code = array();

        $body = $this->getExtraBody();
        $bodyHasOpenTag = preg_match('#(?:\s*)<\?php#', $body);
        $code[] = '<?php';
        $code[] = null;

        // Documentation.
        $doc = $this->generateDocumentation();
        if ($doc !== null) {
            $code[] = $doc;
            $code[] = null;
        }

        foreach ($this->objects as $object) {
            foreach ($object->getUses() as $use => $alias) {
                $this->addUse($use, $alias);
            }
        }

        // If there are objects in different namespaces or some objects are in a different namespace compared to the file namespace.
        if ($this->areMultipleNamespacesInFile() === true) {
            $code = array_merge($code, $this->renderObjects(true));

            $code[] = $this->getIndentation() . 'namespace ' . $this->namespace;
            $code[] = '{';
            $code[] = null;

            // Temporarily add one more level of indentation.
            $this->addIndentationLevel(1);

            $code = array_merge($code, $this->renderRequiredFilesLines());

            $code = array_merge($code, $this->renderUsesLines());

            if ($bodyHasOpenTag > 0) {
                $code[] = '?>';
            }

            if ($this->extraBody !== null) {
                $code[] = $this->extraBody;
            }

            // Set back the indentation.
            $this->addIndentationLevel(-1);

            $code[] = $this->getIndentation() . '}';
        } else {
            if ($this->namespace !== null) {
                $code[] = $this->getIndentation() . 'namespace ' . $this->namespace . ';';
                $code[] = null;
            }

            $code = array_merge($code, $this->renderRequiredFilesLines());

            $code = array_merge($code, $this->renderUsesLines());

            $code = array_merge($code, $this->renderObjects(false));

            if ($bodyHasOpenTag > 0) {
                $code[] = '?>';
            }

            if ($this->extraBody !== null) {
                $code[] = $this->extraBody;
            }
        }

        return implode($this->getLineFeed(), $code);
    }
260626
public function get_renderer() {
        global $PAGE;
        if ($this->output) {
            return $this->output;
        }
        $this->output = $PAGE->get_renderer('mod_assign', null, RENDERER_TARGET_GENERAL);
        return $this->output;
    }
270632
public function renderTable(): string
    {
        $output = '';

        if ($this->tableOptionsInit !== null) {
            $output .= "        {$this->tableOptionsInit}\n\n";
        }

        $output .= "        \$this->createTable('" . $this->renderName() . "', [";

        foreach ($this->columns as $column) {
            $output .= "\n" . $column->render($this);
        }

        $output .= "\n        ]" . ($this->tableOptions !== null ? ", {$this->tableOptions}" : '') . ");\n";

        return $output;
    }
350182
public function render(ResultsRenderer $renderer)
    {
        return sprintf(
            "  %s\n%s\n\n  %s\n%s\n",
            $renderer->style('YOUR OUTPUT:', ['bold', 'yellow']),
            $this->indent($renderer->style(sprintf('"%s"', $this->result->getActualOutput()), 'red')),
            $renderer->style('EXPECTED OUTPUT:', ['bold', 'yellow']),
            $this->indent($renderer->style(sprintf('"%s"', $this->result->getExpectedOutput()), 'green'))
        );
    }