jmf/twig-tabs 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

jmf/twig-tabs

Composer 安装命令:

composer require jmf/twig-tabs

包简介

Tabs extension for Twig

README 文档

README

Renders tabbed content from Twig templates.

Installation

composer require jmf/twig-tabs

Setup

Pass the Twig FilesystemLoader when registering the extension. The @JmfTwigTabs namespace is registered automatically:

$twig->addExtension(new TabsExtension($templateRenderer, $loader));

Usage in Twig templates

tabs() and tab()

{{ tabs(
    tab('articles').label('First tab').content('<p>Content 1</p>'),
    tab('authors').label('Second tab').include('path/to/template.html.twig', {foo: bar}),
    tab('comments').label('With badge').content('<p>Content 3</p>').badge('5'),
) }}

Or passing an array:

{{ tabs(myTabBuilders) }}

tab() builder methods

Method Description
.label(string $label) Tab header label
.content(string $html) Raw HTML content for the tab pane
.include(string $path, array $parameters) Render a template as the tab pane content
.badge(?string $badge) Optional badge displayed next to the label

Customising templates

Override individual templates by pointing $templatePath to your own entry point, or replace the @JmfTwigTabs namespace with your own templates directory. The five templates are:

  • bootstrap/tabs.html.twig — entry point, includes nav and content
  • bootstrap/nav-tabs.html.twig<ul> tab navigation
  • bootstrap/nav-item.html.twig — individual tab <li> + <a>
  • bootstrap/tab-content.html.twig<div class="tab-content"> wrapper
  • bootstrap/tab-pane.html.twig — individual tab pane <div>

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: mit
  • 更新时间: 2026-05-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固