定制 open-solid/sugar-twig 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

open-solid/sugar-twig

Composer 安装命令:

composer require open-solid/sugar-twig

包简介

Syntactic sugar for Twig templates

README 文档

README

A Symfony bundle that brings JSX-like component syntax to Twig.

Installation

composer require open-solid/sugar-twig

How it works

Define a component (templates/components/button.html.twig):

<button {{ html_attrs({'class': 'bg-primary text-primary-foreground', ...props}) }}>
    {%- block content %}{% endblock -%}
</button>

Use it with props and customize as needed:

<Button type="submit" className="h-8 px-2.5">Save</Button>

It compiles to native Twig embed/include calls at load time (native Twig cache involved):

{% embed 'components/button.html.twig' with {props: {type: 'submit' className: 'h-8 px-2.5'}} %}
    {% block content %}Save{% endblock %}
{% endembed %}

Zero runtime overhead, no custom tags to learn.

Final output:

<button type="submit" class="bg-primary text-primary-foreground h-8 px-2.5">Save</button>

Go and try it! https://open-solid.github.io/sugar-twig/

Requirements

Interactive components (dialogs, accordions, tabs, dropdowns, etc.) require Alpine.js and a couple of its plugins. See the Alpine.js setup guide for installation instructions.

统计信息

  • 总下载量: 440
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: Twig

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固