Python的HTML-DSL

html-dsl的Python项目详细描述


HTML DSL

Python的HTML-DSL

使用

>>> from html_dsl.elements import BaseHtmlElement, HTML, BODY, H1, P, DIV, SPAN
>>> html = HTML[
        BODY[
            H1["Title"],
            P(color="yellow")[
                "Hello, World.", SPAN["something in span"], "Out of the span"
            ],
            P["This is the second paragraph."],
            DIV[
                DIV(_class="row")[
                    DIV(_class="column", color="red")["col1"],
                    DIV(_class="column", color="blue")["col2"],
                    DIV(_class="column", color="green")["col3"],
                ]
            ],
        ]
    ]
>>> print(html)
<html>
  <body>
    <h1>
    Title
    </h1>
    <p color="yellow">
    Hello, World.
      <span>
      something in span
      </span>
    Out of the span
    </p>
    <p>
    This is the second paragraph.
    </p>
    <div>
      <div class="row">
        <div color="red" class="column">
        col1
        </div>
        <div color="blue" class="column">
        col2
        </div>
        <div color="green" class="column">
        col3
        </div>
      </div>
    </div>
  </body>
</html>

安装

pip install html_dsl

作者

<>易贤独

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Apache Flink外部Jar   创建和强制转换对象数组时发生java错误   Java,添加数组   具有相同包结构和类的java JAR   java Jenkins未能构建Maven项目   java为什么一个forloop比另一个更快,尽管它们做的“一样”?   servlets在将“/”站点迁移到Java EE包时处理contextpath引用   无法解析java MavReplugin:2.21或其某个依赖项   泛型如何编写比较器来泛化Java中的两种类型的对象?   java Android Emulator未在netbeans上加载   多线程Java使用线程对数组中的数字求和:在同步块中使用新变量作为锁:差异   java如何在JSP/servlet中设置<input>标记的值?