headzoo/polymer-bundle

Symfony 扩展包和 Twig 扩展,用于开发和使用 Polymer 网络组件。

安装: 84

依赖: 0

建议者: 0

安全: 0

星星: 11

关注者: 5

分支: 6

开放问题: 4

类型:symfony-bundle

0.0.5.1 2015-06-14 22:54 UTC

This package is not auto-updated.

Last update: 2024-09-28 17:43:46 UTC


README

Symfony 扩展包和 Twig 扩展,用于开发和使用 Polymer 网络组件。

Build Status Documentation MIT License

Polyphonic Symfony

此包尚未准备好用于生产环境。请自行承担风险。

此包的目的是使在 Symfony 项目中使用和构建 Polymer 网络组件变得更加容易。Polyphonic 可以解决在 Twig 模板中尝试构建和使用网络组件时遇到的问题。

示例元素

使用 {% polymer element %} Twig 标签创建自定义 <hello-world><hello-world> 元素的简单示例。此元素默认显示 "Hello, World!",但可以通过设置 name 属性来更改消息。

请注意,无需添加 <link rel="import" href="polymer/polymer.html">,因为导入语句会自动添加。模板存储在包目录中的 Resources/public/elements/hello-world/hello-world.html.twig

{% polymer element "hello-world" attributes="name" %}
    <template>
        <p>Hello, {{name}}!</p>
    </template>
    <script>
        Polymer({
            name: "World"
        });
    </script>
{% endpolymer %}

在视图中使用元素

{% polymer import "@AcmeBundle:hello-world/hello-world.html.twig" %}

<!-- Displays "Hello, World!" -->
<hello-world></hello-world>

<!-- Displays "Hello, Pascal!" -->
<hello-world name="Pascal"></hello-world>

要求

PHP 5.5.*
Symfony 2.6.*

安装

headzoo/polymer-bundle 添加到您的 composer.json 要求中。

"require": {
    "headzoo/polymer-bundle": "0.0.3"
}

运行 composer update 然后将包添加到您的 AppKernel.php。

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
            ...
            new Headzoo\Bundle\PolymerBundle\PolymerBundle(),
        )
        
        return $bundles;
    }
}

将以下路由添加到您的 app/config/routing_dev.yml 文件中。

polymer:
	resource: "@PolymerBundle/Resources/config/routing.yml"
	prefix:   /_polymer

下一步:阅读完整文档