承接 raichev/twig-turbo-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

raichev/twig-turbo-bundle

最新稳定版本:v1.0.0

Composer 安装命令:

composer require raichev/twig-turbo-bundle

包简介

Opinionated extension for Symfony UX Turbo

README 文档

README

Opinionated extension for Symfony UX Turbo.

This bundle is meant to be used alongside Symfony UX Turbo and provides a fast, simple and efficient way to create turbo frames

Simple example:

  1. We create the frame template ("myFrame.html.twig"), by extending the base and setting the frameId & frameSrc
{% extends 'turbo_frame_base.html.twig' %}

{% set frameId = 'my-frame' %}
{% set frameSrc = path('app_controller_myframe') %}

{% block content %}
    <div>
        My Template Content
    </div>
{% endblock %}
  1. We load the frame in twig using the turboFrame function, passing the frame template as the first argument
{{ turboFrame('myFrame.html.twig'}}
  1. In the controller method we render the frame
    #[Route('/myframe', name: 'myframe', methods: ['GET'])]
    public function myFrame(): Response
    {
        return $this->render(
            'myFrame.html.twig',
        );
    }

By default, the "placeholder" block contains a loading indicator, but if you want a different placeholder in your frame you can override it in step 2

The turboFrame function accepts a few optional arguments:

  • 'variables' => variables passed to the twig template
  • 'loading' => sets the turbo frame attribute of the same name, ['lazy' | 'eager'], 'eager' by default
  • 'autoscroll' => sets the turbo frame attribute of the same name, false by default
  • 'disabled' => sets the turbo frame attribute of the same name, false by default
  • 'withContext' => when true the twig template can access its parent's variables, false by default

The default values above can be changed via the bundle config

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-01-02