zerkalica / millwright-boilerplate-bundle
Symfony2 Millwright 模板包
dev-master
2012-11-24 19:40 UTC
Requires
- symfony/framework-bundle: >=2.0
Suggests
- manymules/jquery-bundle: *
- manymules/modernizr-bundle: *
This package is not auto-updated.
Last update: 2024-09-14 13:53:00 UTC
README
基本HTML布局和内容Twig助手
受OryzoneBoilerplateBundle(https://github.com/Oryzone/OryzoneBoilerplateBundle)启发
功能
- 简单的布局html5.html.twig (无头部/尾部标记)
- 不包含js和css
- Twig配置变量与OryzoneBoilerplateBundle兼容(https://github.com/Oryzone/OryzoneBoilerplateBundle/blob/master/Resources/doc/index.md#available-variables)
- 一些可重用代码移至helpers.html.twig
- 可选使用ManyMulesModernizrBundle(https://github.com/ManyMules/ManyMulesModernizrBundle)和ManyMulesJQueryBundle(https://github.com/ManyMules/ManyMulesJQueryBundle)
安装
php composer.phar update zerkalica/millwright-boilerplate-bundle php composer.phar update manymules/jquery-bundle php composer.phar update manymules/modernizr-bundle
将包添加到您的应用程序内核
// app/AppKernel.php public function registerBundles() { $bundles = array( // ... new ManyMules\JQueryBundle\ManyMulesJQueryBundle, new ManyMules\ModernizrBundle\ManyMulesModernizrBundle, new Millwright\BoilerplateBundle\MillwrightBoilerplateBundle, // ... ); }
示例
{# ::layout.html.twig #}
{% extends 'MillwrightBoilerplateBundle::layout.html.twig' %}
{% import 'MillwrightBoilerplateBundle::helpers.html.twig' as add %}
{% block body_js %}
{{ add.chromeFrame() }}
{{ add.googleJs('jquery/1.8.3/jquery.min.js', 'bundles/manymulesjquery/js/jquery.min.js') }}
{{ add.googleAnalytics(bp_analytics_id|default('')) }}
{% endblock body_js %}
{% block head_js %}
{{ add.js('bundles/manymulesmodernizr/js/modernizr.min.js' }}
{% endblock head_js %}
{% block favicon %}
{{ add.favicon('favicon.ico') }}
{% endblock favicon %}
{% block final_css %}
{{ add.css('twitterbootstrap/responsive.css') }}
{% endblock final_css %}
{# view.html.twig #}
{% extends '::layout.html.twig' %}
{% import 'MillwrightBoilerplateBundle::helpers.html.twig' as add %}
{% block body_content %}
{{ parent() }}
<div id="app"></div>
{% endblock body_content %}
{% block head_css %}
{{ parent() }}
{{ add.css('bundles/myapp/css/main.css') }}
{% endblock head_css %}
{% block body_js %}
{{ parent() }}
{{ add.js('bundles/myapp/js/main.app.js') }}
{% endblock body_js %}
{% block body_js_code %}
{{ parent() }}
<script>
{{ add.readyStart() }}
$('#app').myApp();
{{ add.readyFinish() }}
<script>
{% endblock body_js_code %}
#app/config/config.yml # Twig Configuration twig: debug: %kernel.debug% strict_variables: %kernel.debug% globals: bp_language: %locale%