drez/php-html

一个用于在PHP中编写HTML的类

dev-master 2020-09-30 02:27 UTC

This package is auto-updated.

Last update: 2024-09-29 05:55:55 UTC


README

我讨厌HTML!我讨厌在PHP文件中放入多种语言。所以我使用一个小的类来生成HTML,并添加了一些快捷方式。

所以我可以这样编写HTML

use phpHtml\Html;

$Html = new Html('bootstrap', true);

$Html
    ->jumbotron(null)
        ->addH1("Use HJSON intead of XML for Propel")
        ->addP("This library is part of APIgoat.")
    ->close()
    ->div(null, ['class' => 'card-group'])
        ->div(null, ['class' => 'card'])
            ->div(null, ['class' => 'card-header'])
                ->addSpan("HJSON to Propel XML schema.", ["style" => "display: inline-block;width: 49%;"])
                ->div(null, ["style" => "display: inline-block;width: 50%;text-align: right;"])
                    ->addBut("Convert", ['id' => 'convert', 'type' => 'primary'])
            ->close()
        ->close()
        ->div(null, ['class' => 'card-body'])
            ->addDiv("", ['id' => 'hjson-editor', "style" => "height: 100%; width: 100%"])
        ->close('all', 1)
        ->div(null, ['class' => 'card'])
            ->div(null, ['class' => 'card-header'])
                ->addSpan("HJSON to Propel XML schema.", ["style" => "display: inline-block;width: 49%;"])
                ->div(null, ["style" => "display: inline-block;width: 50%;text-align: right;"])
                ->addBut("Download schema", ['id' => 'download', 'type' => 'primary'])
            ->close()
        ->close()
        ->div(null, ['class' => 'card-body'])
        ->addDiv("", ['id' => 'xml-editor', 'addclass' => 'editor', "style" => "height: 100%; width: 100%"])
    ->close('all');

    $html =  $Html->body(null, ['class' => 'body'])->addContainerFull($Html->getBuffer())->close()->getPage();

特性

  • 易于添加最常用标签的快捷方式
  • 如有需要,自动添加类

使用

composer require drez/php-html