定制 fousky/jsblock 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fousky/jsblock

最新稳定版本:4.3.0

Composer 安装命令:

composer require fousky/jsblock

包简介

Collect & render javascripts at the end of your template.

关键字:

README 文档

README

The Symfony JSBlockBundle gives you a chance to collect javascript across all TWIG templates (e.g. forms) and render them at the end of your layout (or anywhere you want them).

Build Status Scrutinizer Code Quality

1. Install it by composer

composer require fousky/jsblock

2. Register bundle in Kernel

public function registerBundles()
{
    $bundles = array(
        new Fousky\JSBlockBundle\FouskyJSBlockBundle(),
        // ... your custom bundles
    );
    
    // ... your custom dev bundles
    
    return $bundles;
}

3. Render collected javascripts to your main template

I assume you have the main template layout.html.twig, so add {% jsblock 'render' %} before closing </body> tag.

Of course you can put this tag anywhere you want to render collected javascripts.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>my page</title>
</head>
<body>

<!-- APPLICATION LOGIC -->

<!-- render collected javascripts -->
{% jsblock 'render' %}

</body>
</html>

4. Collect javascripts anywhere

Now you can collect javascripts anywhere you want. You have to start collecting by tag: {% jsblock 'start' %} and close it by tag {% jsblock 'stop' %}.

<!-- CUSTOM LOGIC -->

<!-- need some javascript? Start rendering -->
{% jsblock 'start' %}
    <script>
        $(document).ready(function() {
            console.log('Hello from collected JSBlockBundle!');
        });
    </script>
{% jsblock 'stop' %}
<!-- and close collecting -->

统计信息

  • 总下载量: 664
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-09-25