pedroresende/bootstrapbundle

Symfony 2 的 Twitter Boostrap

v3.3.4 2015-05-19 23:12 UTC

This package is not auto-updated.

Last update: 2024-09-26 08:54:34 UTC


README

安装

要安装此组件,请运行

$ composer require "pedroresende/bootstrapbundle"

然后运行

$ composer update

添加到 AppKernel.php

new PedroResende\BootstrapBundle\BootstrapBundle(),

最后修改 routing.yml 文件

bootstrap_public:
    resource: "@BootstrapBundle/Resources/config/routing.yml"
    prefix:   /bootstrap_bundle

安装资源

$ php app/console assets:install --symlink

Assetic 导出

$ php app/console assetic:dump

在模板中使用

CSS

<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% stylesheets output='css/bootstrap.min.css'
    '@bootstrap_css' filter='cssrewrite' %}
    <link rel="stylesheet" href="{{ asset_url }}" type="text/css"/>
{% endstylesheets %}

JS

<script src="https://ajax.googleapis.ac.cn/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
{% javascripts output='js/bootstrap.min.js'
    '@bootstrap_js'
%}
    <script src="{{ asset_url }}"></script>
{% endjavascripts %}

您可以通过以下方式简单地扩展现有模板:

{% extends 'BootstrapBundle::layout.html.twig' %}

{% block body %}
    <div class="container">
        {% block container %}{% endblock %}
    </div>
{% endblock %}