Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- - A simple HTML Rendering system.
- - Easy create static HTML Pages!
- */
- namespace BTTM;
- class HTML {
- public $type;
- public $content;
- public $head;
- public $page;
- function __constuct() {
- $this->type = 'html';
- $this->pageContent = '';
- }
- private function head($txt) {
- $this->head .= $txt;
- }
- function title($t = 'My site') {
- $this->head('<title>'.$t.'</title>');
- }
- function link($link = 'index.php', $text = null) {
- if ($text != null) {
- return '<a href="'.$link.'">'.$text.'</a>';
- } else {
- return '<a href="'.$link.'">'.$link.'</a>';
- }
- }
- function addElement($type = 'div', $text = 'DIV CONTENT', $att = null) {
- $at = '';
- if ($att != null) {
- $at .= ' ';
- foreach ($att as $a => $v) {
- $at .= $a . '="' . $v . '" ';
- }
- }
- if (is_array($text)) {
- $text = join($text, '');
- }
- $this->pageContent .= '<'.$type.''.$at.'>'.$text.'</'.$type.'>';
- }
- function render() {
- $this->content = '<!DOCTYPE html><html><head><meta name="viewport" content="width=device-width, initial-scale=1.0">';
- $style = '';
- $style .= 'body {font-family:sans-serif;} a{color:blue;text-decoration:underline;font-weight: bold;}';
- $this->head('<style>'.$style.'</style>');
- $this->content .= $this->head;
- $this->content .= '</head><body>';
- $this->content .= $this->pageContent;
- $this->content .= '</body>';
- echo $this->content;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment