youlead-bow/twig
最新稳定版本:v1.5.3
Composer 安装命令:
composer require youlead-bow/twig
包简介
Provides many extension tag
README 文档
README
Provides a {% switch %} tag for Twig switch case statements.
Provides a {% includeDir %} tag for Twig
Provides a {% useDir %} tag for Twig
1. switch
Usage
{% switch myVar %}
{% case 'value1' %}
{# ...code here to run for value1 #}
{% case 'value2' %}
{# ...code here to run for value2 #}
{% default %}
{# ...code here to run for default when no case matched #}
{% endswitch %}
2. includeDir
Usage
{% includeDir '/popups' %}
The files in the directory will be included alphabetically.
Recursive usage
To include all files within a given directory recursive simply add the keyword recursive to your include statement:
<div class="modal-container"> {% includeDir '/popups' recursive %} </div>
Now also the popups from the directories /popups/user and /popups/system etc. will be included.
Caution: The templates will be included alphabetically as well, including the directories. Thus the template /popups/footer.twig will be included before the templates from the directory /popups/system followed by /popups/user followed by a possible /popups/zebraHeader.twig. It is recommended to use includeDir only for templates which do not require a specific order.
Variables
As known from the Twig Core include you can control the available variables with the keywords with and only (compare: include)
<div class="modal-container"> {# only the foo variable will be accessible #} {% includeDir '/modals' recursive with {'foo': 'bar'} only %} </div>
2. useDir
Usage
{% useDir '/form/specials' %}
The files in the directory will be included alphabetically.
Recursive usage
To use all files within a given directory recursive simply add the keyword recursive to your use statement:
{% useDir '/form/specials' recursive %}
Now also the popups from the directories /form/specials and /form/field etc. will be used.
Caution: The templates will be used alphabetically as well, including the directories. Thus the template /form/field/select.twig will be included before the templates from the directory form/specials. It is recommended to use useDir only for templates which do not require a specific order.
统计信息
- 总下载量: 58
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-only
- 更新时间: 2023-06-21