Show HN: Pyfrontkit 更新

1作者: Edybrown6 个月前
从 Python 生成前端通常比必要的更复杂,尤其是在将设计与后端逻辑集成时。 Pyfrontkit (v1.1.10) 是一个旨在减少这种摩擦的 Python 库。 它的方法基于三个理念:简单性、效率和控制。 使用 Pyfrontkit,前端的定义代码量远少于传统的 HTML + CSS。 在许多情况下,书写字符的减少超过 50%,从而减少了噪音和潜在的错误点。 单个设计定义可以根据上下文生成不同的输出: * 写入磁盘的 HTML + CSS * 内存生成 * 嵌入或分离的样式 所有这些都来自同一个源。 模板不是被动文件,而是 Python 函数。 它们被封装一次,并在不创建多个变体的情况下重复使用。 由于模板是函数,它们可以接收包含以下内容的参数: * 数据(内容) * 设计值(颜色、样式、视觉行为) 这使得同一个模板可以动态适应,而无需复制代码。 使用模板不会引入额外的摩擦: 它像任何常规的 Python 函数一样从后端逻辑中调用,使与 Python 框架的集成变得简单。 结果是一个更简单的工作流程,更少的层,更少的需要学习的概念,以及开发人员更多的控制权。 分享一些带有此版本流程视觉示例的图片<p>链接:GitHub:<a href="https:&#x2F;&#x2F;github.com&#x2F;Edybrown&#x2F;Pyfrontkit" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Edybrown&#x2F;Pyfrontkit</a> PyPI:<a href="https:&#x2F;&#x2F;pypi.org&#x2F;project&#x2F;pyfrontkit&#x2F;" rel="nofollow">https:&#x2F;&#x2F;pypi.org&#x2F;project&#x2F;pyfrontkit&#x2F;</a>
查看原文
Generating frontend from Python often involves more complexity than necessary, especially when integrating design with backend logic. Pyfrontkit (v1.1.10) is a Python library designed to reduce that friction. Its approach is based on three ideas: simplicity, efficiency and control. With Pyfrontkit, frontend is defined with significantly less code than traditional HTML + CSS. In many cases, the reduction exceeds 50% in written characters, reducing noise and potential error points. A single design definition can produce different outputs depending on the context: HTML + CSS written to disk In-memory generation Embedded or separated styles All from the same source. Templates are not passive files, but Python functions. They are encapsulated once and reused without creating multiple variants. Since templates are functions, they can receive arguments containing: data (content) design values (colors, styles, visual behavior) This allows the same template to adapt dynamically without duplicating code. Using a template introduces no additional friction: it is called like any regular Python function from backend logic, making integration with Python frameworks straightforward. The result is a simpler workflow with fewer layers, fewer concepts to learn and more control for the developer. Sharing a few img with visual examples of the flow in this version<p>Links: GitHub: <a href="https:&#x2F;&#x2F;github.com&#x2F;Edybrown&#x2F;Pyfrontkit" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Edybrown&#x2F;Pyfrontkit</a> PyPI: <a href="https:&#x2F;&#x2F;pypi.org&#x2F;project&#x2F;pyfrontkit&#x2F;" rel="nofollow">https:&#x2F;&#x2F;pypi.org&#x2F;project&#x2F;pyfrontkit&#x2F;</a>