heimrichhannot / contao-replace-bundle
前端页面执行正则表达式搜索和替换的contao辅助包。
1.3.0
2024-03-28 12:23 UTC
Requires
- php: ^7.4 || ^8.0
- contao/core-bundle: ^4.13 || ^5.0
- heimrichhannot/contao-multi-column-editor-bundle: ^1.2 || ^2.4
- symfony/dependency-injection: ^4.4 || ^5.4 || ^6.0
Requires (Dev)
- contao/manager-plugin: ^2.0
- contao/test-case: ^1.1
- friendsofphp/php-cs-fixer: ^2.2
- php-coveralls/php-coveralls: ^2.0
- php-http/guzzle6-adapter: ^1.1
- php-http/message-factory: ^1.0.2
- phpunit/phpunit: >=6.0 <6.5
- symfony/phpunit-bridge: ^3.2
README
前端页面执行正则表达式搜索和替换的contao辅助包。
配置
目前只能进行全局搜索和替换。打开contao设置并配置自定义搜索和替换模式。
示例
将标题文本包裹在 <span>
标签中
之前: <h1>Test A</h1>
之后: <h1><span>Test A<span></h1>
- 模式:
(<h\d[^>]*>)(.*)(<\/h[^>]*>)
- 替换:
$1<span>$2</span>$3
Bootstrap 4 响应式表格
之前: <table><thead><tr><th>Value</th></tr></thead><tbody><tr><td>1</td></tr></tbody></table></body></html>
之后: <div class="table-responsive"><table class="table table-bordered table-hover"><thead><tr><th>Value</th></tr></thead><tbody><tr><td>1</td></tr></tbody></table></div>
- 模式:
(<table>)(.*)(<\/table>)
- 替换:
<div class="table-responsive"><table class="table table-bordered table-hover">$2</table></div>
替换链接中的文件路径
之前: <a href="tl_files/subfolder/files/file.pdf">Test link</a>
之后: <a href="files/backup/file.pdf">Test link</a>
- 模式:
(tl_files\/subfolder\/files\/)
- 替换:
<div class="table-responsive"><table class="table table-bordered table-hover">$2</table></div>
- 替换标签: true (勾选)