acalvino4/craft-twig-ruleset 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

acalvino4/craft-twig-ruleset

最新稳定版本:1.0.3

Composer 安装命令:

composer require acalvino4/craft-twig-ruleset

包简介

A twig coding style ruleset for the Craft community

README 文档

README

In the effort to automate as much style checking as possible, twig files would ideally not be missed in a Craft CMS project.

There is a good package for this, but it misses Craft conventions on a couple points.

  • camelCase variable names, instead of snake_case
  • use of the fairly ubiquitous empty coalesce operator from Andrew Welch

The ruleset provided here maintains the official ruleset, with the exception of addressing the two issues above. I am happy to consider further modifications requests / PR's if it can be demonstrated that they would be warranted by the Craft community.

Usage

Install

composer require --dev acalvino4/craft-twig-ruleset

Configure

<?php

// .twig_cs.php in project root

declare(strict_types=1);

use acalvino4\crafttwigruleset\CraftRuleset;
use FriendsOfTwig\Twigcs\Config\Config;
use FriendsOfTwig\Twigcs\Finder\TemplateFinder;

return Config::create()
    ->addFinder(TemplateFinder::create()->in('templates'))
    ->setRuleSet(CraftRuleset::class)
;

This config format is straight from twigcs, so any customizations or alternatives file names noted there will work as well. The only unique thing here is use of CraftRuleset.

Run

./vendor/bin/twigcs

Alternatively, add a composer script that calls twigcs, and/or use an IDE extension like Twigcs Linter.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-06