承接 starxen/lasertag 相关项目开发

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

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

starxen/lasertag

最新稳定版本:v1.0.2

Composer 安装命令:

composer require starxen/lasertag

包简介

LaserTag - A Symfony bundle for creating and rendering your own templates.

README 文档

README

LaserTag is a Symfony bundle that allows you to write and render your own HTML templates based on your own BBCode-style tags. By using LaserTag, we gain reusability and independence of the content from the accompanying HTML code.

Example

Before render

[h2 class="extra-class-name"]Check my new YouTube video![/h2]
[youtube url="https://www.youtube.com/watch?v=dQw4w9WgXcQ"/]

After render

<h2 class="app-color-darken fw-bolder mt-3 mb-3 extra-class-name">Check my new YouTube video!</h2>
<div class="app-border-left-bold embed-responsive embed-responsive-16by9 col col-lg-6 mx-auto mt-3 mb-3">
    <iframe class="embed-responsive-item" src="https://www.youtube.com/watch?v=dQw4w9WgXcQ" title="" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div>

LaserTag Plugin

// src/LaserTag/MyPlugin.php
<?php

declare(strict_types=1);

namespace App\LaserTag;

use StarXen\LaserTag\LaserTag\AbstractPlugin;
use StarXen\LaserTag\LaserTag\LaserTag;
use StarXen\LaserTag\LaserTag\TagAttribute;

class MyPlugin extends AbstractPlugin
{
    public function getTags(): array
    {
        return [
            new LaserTag('h2', [$this, 'h2'], [new TagAttribute('class')]),
            new LaserTag('youtube', [$this, 'youtube'], [new TagAttribute('url', true), new TagAttribute('title')])
        ];
    }

    public function h2(string $content): string
    {
        return <<<HTML
<h2 class="app-color-darken fw-bolder mt-3 mb-3 {$this->getAttribute('class')}">$content</h2>
HTML;
    }

    public function youtube(): string
    {
        return <<<HTML
<div class="app-border-left-bold embed-responsive embed-responsive-16by9 col col-lg-6 mx-auto mt-3 mb-3">
    <iframe class="embed-responsive-item" src="{$this->getAttribute('url')}" title="{$this->getAttribute('title')}" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div>
HTML;
    }
    
}

Installation

composer require starxen/lasertag

Usage

See EXAMPLE.md

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-03-13