carlcs / craft-glob
此包的最新版本(v1.0.1)没有可用的许可信息。
Craft CMS 的 Glob 插件
v1.0.1
2016-02-02 23:01 UTC
Requires
- php: >=5.3.0
- composer/installers: ~1.0
This package is auto-updated.
Last update: 2024-09-20 04:40:38 UTC
README
Craft 插件,向模板文件夹添加 Twig 函数以查找匹配模式的路径名。
该插件内部使用 PHP glob
函数。
安装
要安装插件,将 glob/ 文件夹复制到 craft/plugins/ 中。然后转到设置 → 插件,并点击 "Glob" 旁边的 "安装" 按钮。
Twig 函数
glob( path, pattern )
在您的模板文件夹中查找匹配模式的路径名。
{% set plugins = [ 'Asset Metadata', 'Number Convert', ] %} {% for plugin in plugins %} {% set dirPath = 'tests/' ~ plugin|camel|lower ~ '/' %} {% for path in glob(dirPath) %} <a href="/{{ path }}">{{ path }}</a> {% endfor %} {% endfor %}
参数
path
(可选) : 要搜索的 craft/templates/ 中的子路径。
pattern
(可选) : PHP glob
文档中描述的模式(默认值是 '*.{html,twig}'
)。