h4md1/jsqueeze-bundle

此捆绑包允许你在twig模板中使用jsqueeze。

安装: 16

依赖: 0

建议者: 0

安全: 0

星标: 1

关注者: 2

分支: 0

开放问题: 0

类型:symfony-bundle

0.0.1 2015-03-01 17:04 UTC

This package is not auto-updated.

Last update: 2024-09-18 06:26:55 UTC


README

SensioLabsInsight

此捆绑包允许你在twig模板中使用jsqueeze。

安装

步骤 1:使用 Composer 安装 H4md1JsqueezeBundle

composer.json 中添加 JsqueezeBundle

{
    "require": {
        "h4md1/jsqueeze-bundle": "dev-master"
    }
}

现在运行以下命令让Composer下载捆绑包

$ php composer.phar update h4md1/jsqueeze-bundle

步骤 2:启用捆绑包

在kernel中启用捆绑包

<?php

// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        // ...
        new H4md1\JsqueezeBundle\H4md1JsqueezeBundle(),
        // ...
        );
    }

用法

{% block content %}
    <h1>Hello {{ name }}!</h1>
    <script>
        {%- jsqueeze -%}
        (function(str)
        {
            var newstr;
            if('' !== str){
                newstr = str+'#'+str;
            }
            else{
                newstr = 'empty';
            }
        })('twice');
        {%- endjsqueeze -%}
    </script>
{% endblock %}

以下代码将输出

<h1>Hello {{ name }}!</h1>
<script>(function(e){var i;if(''!==e){i=e+'#'+e}else{i='empty'}})('twice');</script>

已知限制和错误

肯定很多

许可证

此捆绑包受MIT许可证许可。