sitegeist / fluid-tagbuilder
用于提高复杂流体模板可读性的html5标签ViewHelpers
1.0.1
2024-08-28 12:10 UTC
Requires
- php: ^8.2
- typo3fluid/fluid: <=2.14.1
Requires (Dev)
This package is auto-updated.
Last update: 2024-08-28 12:13:18 UTC
README
这是一个尝试使具有大量动态组合HTML标签的复杂Fluid模板更易读的尝试。
免责声明:这不是万能解决方案,仅在适当的情况下使用,绝对不能用于模板中的所有标签!
之前
<button class="{class} {f:if(condition: isBold, then: 'bold')} {f:if(condition: isActive, then: 'active')}" data-items="{data.items}" data-count="{data.count}" {f:if(condition: title, then: 'title="{title}"')} ><f:spaceless> More content </f:spaceless></button>
之后
<ft:button class="{class}" :classList="{ 'bold': isBold, 'active': isActive }" :dataList="{data}" :spaceless="1" title="{title}" > More content </ft:button>
入门
通过composer安装库 链接
composer require sitegeist/fluid-tagbuilder
... 然后在模板中使用它
<html xmlns:ft="http://typo3.org/ns/Sitegeist/FluidTagbuilder/ViewHelpers" data-namespace-typo3-fluid="true">
特性
- 支持HTML规范中当前定义的所有标签(见下文)
- 支持所有当前定义的
booleanHTML5属性- 如果
true:添加required="required"属性 - 如果
false:不添加属性
- 如果
- 移除空标签属性
- 从
:classList="{...}"生成优化的类属性 - 从
:dataList="{...}"生成数据属性 - 从
:attributeList="{...}"生成额外的标签属性 - 使用
:spaceless="1"缩短空格
支持的HTML标签
此扩展包括以下HTML5元素的简写 链接
aabbraddressareaarticleasideaudio(带有autplay、controls、loop、muted作为额外的布尔属性)bbasebdibdoblockquotebodybrbutton(带有disabled、formnovalidate作为额外的布尔属性)canvascaptioncitecodecolcolgroupdatadatalistdddeldetails(带有open作为额外的布尔属性)dfndialog(带有open作为额外的布尔属性)divdldtemembedfieldset(带有disabled作为额外的布尔属性)figcaptionfigurefooterform(带有novalidate作为额外的布尔属性)h1h2h3h4h5h6headheaderhgrouphrhtmliiframe(带有allowfullscreen作为额外的布尔属性)img(带有ismap作为额外的布尔属性)input(带有checked、disabled、formnovalidate、multiple、readonly、required作为额外的布尔属性)inskbdlabellegendlilink(带有disabled作为额外的布尔属性)mainmapmarkmathmenumetameternavnoscriptobjectol(带有reversed作为额外的布尔属性)optgroup(带有disabled作为额外的布尔属性)option(带有disabled、selected作为额外的布尔属性)outputpparampicturepreprogressqrprtrubyssampscript(带async、defer、nomodule作为附加的布尔属性)章节select(带disabled、multiple、required作为附加的布尔属性)插槽小号源span粗体样式下标摘要上标svg表格表格体表格单元格模板textarea(带disabled、readonly、required作为附加的布尔属性)表格页脚表头单元格表格头部时间标题表格行track(带default作为附加的布尔属性)下划线无序列表变量video(带autoplay、controls、loop、muted、playsinline作为附加的布尔属性)换行
所有列出的元素都支持以下布尔属性
自动聚焦隐藏项作用域