yivi / very-simple-html-writer
这是一个非常简单的HTML编写器
0.1.0
2018-04-11 16:29 UTC
Requires
- php: ^7.1
This package is auto-updated.
Last update: 2024-09-05 02:38:30 UTC
README
没有安全带。没有速度限制。没有降落伞。什么都没有。这是一个HTML派对,清理器和错误检查器没有被邀请。XSS大观园!
我想找到一个快速生成简单项目HTML的方法。除非你清楚自己在做什么以及为什么这么做,否则你不应该在任何地方使用这个。即使如此,你也不应该这么做。
用法(非常初级,变化很大)
$writer = new HtmlWriterService(); $main_layout = $writer->layout('main'); $openBody = $writer->tag('body')->leaveOpen(); $title = $writer->fragment('hello, world!'); $h1 = $writer->tag('h1')->content($title); $main_layout->addParts($openBody, $h1); $ul_nav = $writer->tag('ul') ->attribute('role', 'navigation') ->addClass('navigation') ->id('navigation'); $nav_li_layout = $writer->layout('nav'); $li_home = $writer->tag('li')->content($writer->fragment('Home')); $li_contact = $writer->tag('li')->content($writer->fragment('Contact')); $li_about = $writer->tag('li')->content($writer->fragment('About')); $nav_li_layout->addParts($li_home, $li_contact, $li_about); $ul_nav->content($nav_li_layout); $closeBody = $writer->tag('body')->justClose(); $main_layout->addParts($ul_nav, $closeBody) echo $main_layout->compile();