serega3000/twig-grid

用于 Bootstrap 网格布局的 Twig 扩展

1.2 2016-04-01 03:51 UTC

This package is not auto-updated.

Last update: 2024-09-14 18:04:22 UTC


README

#用于 Bootstrap 网格布局的 Twig 扩展

编写此代码

<div class='row'>
    <div class='col col-lg-4 col-md-8 col-sm-6'>
        some content here ...
    </div>
    <div class='col col-lg-4 col-md-8 col-sm-6'>
        some content here ...
    </div>
</div>

在 twig 模板中,您可以编写

{% row %}
    {% col "lg4 md8 sm6" %}
        some content here ...
    {% endcol %}
    {% col "lg4 md8 sm6" %}
        some content here ...
    {% endcol %}
{% endrow %}

在 {% col %} 标签中定义类,例如 "lg4 md8 sm6 xs8",将自动转换为 "col col-lg-4 col-md-8 col-sm-6 col-sx-8"

您还可以为列添加自己的 CSS 类,例如 "lg4 md8 sm6 my-class" 将自动转换为 "col col-lg-4 col-md-8 col-sm-6 my-class"

##安装

在 composer 中要求

composer require serega3000/twig-grid:^1.2

注册为 twig 扩展

$twig = new Twig_Environment($loader);
$twig->addExtension('', new \Serega3000\TwigGrid\Extension());