Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Release] 2.0.0 #32

Merged
merged 33 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
017006a
Merge tag '1.3.6' into develop
titouanmathis Apr 18, 2024
59569aa
Add .github/renovate.json
renovate-bot May 7, 2024
5269563
Merge pull request #25 from studiometa/renovate/configure
titouanmathis Sep 26, 2024
e35b643
Fix renderAttributes to always render alt has it is a mandatory attri…
perruche Sep 18, 2024
f257cf8
Update changelog
perruche Sep 18, 2024
f9807cc
Fix tests
titouanmathis Sep 26, 2024
6134a42
Update minimum PHP version to 8.1
titouanmathis Jan 17, 2025
cf300bf
Fix some Twig deprecation
titouanmathis Jan 17, 2025
2299c90
Update dev dependencies
titouanmathis Jan 17, 2025
ce570d1
Update snapshots
titouanmathis Jan 17, 2025
05a297b
Update Pest configuration
titouanmathis Jan 17, 2025
ecc45c0
Migrate deprecated Twig features
titouanmathis Jan 17, 2025
603851d
Update PHP version in GitHub Actions
titouanmathis Jan 17, 2025
9923e40
Add a PR template
titouanmathis Jan 17, 2025
3f5f365
Fix Twig v3 compatibility
titouanmathis Jan 20, 2025
3d2b5c9
Fix PHPStan errors
titouanmathis Jan 20, 2025
eb469d5
Update linting scripts
titouanmathis Jan 20, 2025
b2fef46
Fix GitHub actions
titouanmathis Jan 20, 2025
ee6caea
Update changelog
titouanmathis Jan 20, 2025
81a64f5
Update badges
titouanmathis Jan 20, 2025
a60fa8d
Merge pull request #30 from studiometa/feature/php-81
titouanmathis Jan 20, 2025
bfa3cd1
Update README
titouanmathis Jan 20, 2025
88ede6d
Remove deprecated templates
titouanmathis Jan 20, 2025
b1d5a48
Remove deprecated functions and filters
titouanmathis Jan 20, 2025
6519ed6
Update tests
titouanmathis Jan 20, 2025
cfb0ba3
Update the changelog
titouanmathis Jan 20, 2025
ad1a81d
Update docs
titouanmathis Jan 20, 2025
63d8f2f
Merge pull request #31 from studiometa/feature/remove-deprecations
titouanmathis Jan 20, 2025
2deab1a
Merge tag '1.3.7' into develop
titouanmathis Jan 20, 2025
ffcf361
Update spatie/url to ^2.4
titouanmathis Jan 20, 2025
2b8fa00
Bump version number
titouanmathis Jan 20, 2025
7d9c9e9
Update changelog
titouanmathis Jan 20, 2025
9b22971
Update GitHub actions
titouanmathis Jan 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!---
☝️ PR title should be prefixed by [Feature], [Bugfix], [Release] or [Hotfix]
-->

### 🔗 Linked issue

<!-- Please ensure there is an open issue and mention its number as #123 -->

### ❓ Type of change

<!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply. -->

- [ ] 📖 Documentation (updates to the documentation, readme or JSdoc annotations)
- [ ] 🐞 Bug fix (a non-breaking change that fixes an issue)
- [ ] 👌 Enhancement (improving an existing functionality like performance)
- [ ] ✨ New feature (a non-breaking change that adds functionality)
- [ ] 🧹 Chore (updates to the build process or auxiliary tools and libraries)
- [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

### 📚 Description

<!-- Describe your changes in detail -->
<!-- Why is this change required? What problem does it solve? -->
<!-- If it resolves an open issue, please link to the issue here. For example "Resolves #1337" -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

- [ ] I have linked an issue or discussion.
- [ ] I have added tests (if possible).
- [ ] I have updated the documentation accordingly.
- [ ] I have updated the changelog.
6 changes: 6 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"github>studiometa/renovate"
]
}
75 changes: 75 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: code-quality

on:
push:
branches:
- master
- develop
pull_request:

jobs:
phpcs:
name: phpcs
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: ['8.1', '8.2', '8.3', '8.4']
steps:
- uses: actions/checkout@v4

- name: Setup PHP, with composer and xdebug
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
coverage: xdebug

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-reqs

- name: PHPCS
run: composer run lint:style

phpstan:
name: phpstan
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: ['8.1', '8.2', '8.3', '8.4']
steps:
- uses: actions/checkout@v4

- name: Setup PHP, with composer and xdebug
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
coverage: xdebug

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-reqs

- name: PHPStan
run: composer run lint:static
35 changes: 11 additions & 24 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release
name: release

on:
push:
Expand All @@ -9,32 +9,19 @@ jobs:
release:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: '0'
- uses: actions/checkout@v4

# @see https://github.com/actions/create-release/issues/38#issuecomment-715327220
# @see https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#environment-files
- name: Prepare the changelog from the tag message
id: prepare_changelog
run: |
PRERELEASE=false
# Check release type
- run: |
IS_PRERELEASE=false
if [[ $GITHUB_REF_NAME =~ 'alpha' || $GITHUB_REF_NAME =~ 'beta' || $GITHUB_REF_NAME =~ 'rc' ]]; then
echo "This is a prerelease."
PRERELEASE=true
IS_PRERELEASE=true
fi
echo "is_prerelease=$PRERELEASE" >> $GITHUB_ENV
echo "IS_PRERELEASE=$IS_PRERELEASE" >> $GITHUB_ENV

# @see https://github.com/actions/create-release
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: ncipollo/release-action@v1
with:
tag_name: ${{ github.ref }}
release_name: v${{ github.ref_name }}
body: Please refer to [CHANGELOG.md](https://github.com/studiometa/twig-toolkit/blob/${{ github.ref_name }}/CHANGELOG.md) for details.
tag: ${{ github.ref }}
name: v${{ github.ref_name }}
body: Please refer to [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/${{ github.ref_name }}/CHANGELOG.md) for details.
draft: false
prerelease: ${{ env.is_prerelease }}
prerelease: ${{ env.IS_PRERELEASE }}
69 changes: 9 additions & 60 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tests
name: tests

on:
push:
Expand All @@ -8,69 +8,17 @@ on:
pull_request:

jobs:
phpcs:
name: PHPCS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Cache Composer dependencies
uses: actions/cache@v2
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}

- uses: php-actions/composer@v5

- name: PHPCS
run: composer run phpcs

phpstan:
name: PHPStan
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: ['7.4', '8.0', '8.1', '8.2', '8.3']
steps:
- uses: actions/checkout@v2

- name: Setup PHP, with composer and xdebug
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
coverage: xdebug

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: PHPStan
run: composer run phpstan

test:
name: Unit test
name: pest
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: ['7.4', '8.0', '8.1', '8.2', '8.3']
twig-versions: ['^2.10', '^3']
php-versions: ['8.1', '8.2', '8.3', '8.4']
env:
PHP_VERSION: ${{ matrix.php-versions }}
TWIG_VERSION: ${{ matrix.twig-versions }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup PHP, with composer and xdebug
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
Expand All @@ -90,10 +38,11 @@ jobs:
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
run: composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-reqs

- name: Install Twig specific version
run: composer require twig/twig:${{ matrix.twig-versions }}
- name: Install Pest v3
run: composer require pest/pest:^3.0
if: ${{ matrix.php-version == '8.4' }}

- name: Pest
run: php -v && XDEBUG_MODE=coverage ./vendor/bin/pest --coverage --coverage-clover='coverage.xml'
Expand All @@ -102,7 +51,7 @@ jobs:
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
env_vars: PHP_VERSION,TWIG_VERSION
env_vars: PHP_VERSION
file: ./coverage.xml
flags: unittests
fail_ci_if_error: false
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
/vendor/

.phpunit.result.cache
/.phpunit.cache/
coverage.xml
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

## v2.0.0 (2025-01-20)

### Changed

- ⚠️ Update minimum Twig version to 3.0 ([#30](https://github.com/studiometa/twig-toolkit/pull/30))
- ⚠️ Update minimum PHP version to 8.1 ([#30](https://github.com/studiometa/twig-toolkit/pull/30), [6134a42](https://github.com/studiometa/twig-toolkit/commit/6134a42))
- Update spatie/url to ^2.4 ([ffcf361](https://github.com/studiometa/twig-toolkit/commit/ffcf361))

### Removed

- ⚠️ Removes the `merge_html_attributes()` Twig filter, use the `merge_html_attributes` function instead ([#31](https://github.com/studiometa/twig-toolkit/pull/31))
- ⚠️ Removes the `class` Twig function, use the `html_classes` function instead ([#31](https://github.com/studiometa/twig-toolkit/pull/31))
- ⚠️ Removes the `attributes` Twig function, use the `html_attributes` function instead ([#31](https://github.com/studiometa/twig-toolkit/pull/31))
- ⚠️ Removes the `@meta` alias without replacement ([#31](https://github.com/studiometa/twig-toolkit/pull/31))

## v1.3.7 (2024-09-18)

### Fixed
Expand Down
23 changes: 6 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Twig toolkit
# studiometa/twig-toolkit

[![Packagist Version](https://img.shields.io/github/v/release/studiometa/twig-toolkit?include_prereleases&label=packagist&style=flat-square)](https://packagist.org/packages/studiometa/twig-toolkit)
[![License MIT](https://img.shields.io/packagist/l/studiometa/twig-toolkit?style=flat-square)](https://github.com/studiometa/twig-toolkit/blob/master/LICENSE)
[![Packagist Version](https://img.shields.io/github/v/release/studiometa/twig-toolkit?style=flat&colorB=3e63dd&colorA=414853&label=packagist)](https://packagist.org/packages/studiometa/twig-toolkit)
[![Downloads](https://img.shields.io/packagist/dm/studiometa/twig-toolkit?style=flat&colorB=3e63dd&colorA=414853)](https://packagist.org/packages/studiometa/twig-toolkit)
[![Dependency Status](https://img.shields.io/librariesio/github/studiometa/twig-toolkit?style=flat&colorB=3e63dd&colorA=414853)](https://packagist.org/packages/studiometa/twig-toolkit)
![Codecov](https://img.shields.io/codecov/c/github/studiometa/twig-toolkit?style=flat&colorB=3e63dd&colorA=414853)
[![License MIT](https://img.shields.io/packagist/l/studiometa/twig-toolkit?style=flat&colorB=3e63dd&colorA=414853)](https://github.com/studiometa/twig-toolkit/blob/master/LICENSE)

> A set of useful extension and components for Twig.

Expand All @@ -21,22 +24,8 @@ $twig = new \Twig\Environment($loader);
$twig->addExtension(new \Studiometa\TwigToolkit\Extension());
```

If you pass a `Twig\Loader\FilesystemLoader` instance to the extension constructor, a `meta` namespace pointing to the `templates/` folder of this package will be added. You will then be able to include components from this package with the `@meta` alias:

```twig
{% include '@meta/components/signature' %}
```

## Reference

### Namespace

When provided with a `\Twig\Loader\FilesystemLoader` parameter, the extension will register a `@meta` namespace referring to the `templates` folder of this package. You will be able to import file in this folder directly from you project's templates:

```twig
{% include '@meta/components/signature.twig' %}
```

### Functions

#### `{{ html_classes(<classes>) }}`
Expand Down
19 changes: 11 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,23 @@
"description": "A set of useful extension and components for Twig.",
"license": "MIT",
"require": {
"php": "^7.3|^8.0",
"twig/twig": "^2.10|^3",
"php": "^8.1",
"twig/twig": "^3.0",
"jawira/case-converter": "^3.4",
"spatie/url": "^1.3"
"spatie/url": "^2.4"
},
"require-dev": {
"phpstan/phpstan": "^0.12.88",
"phpstan/phpstan": "^2.0",
"squizlabs/php_codesniffer": "^3.6",
"pestphp/pest": "^1.22",
"spatie/pest-plugin-snapshots": "^1.0"
"pestphp/pest": "^2.0|^3.0",
"spatie/pest-plugin-snapshots": "^2.0"
},
"scripts": {
"phpcs": "phpcs",
"phpstan": "phpstan analyse",
"lint": ["@lint:style", "@lint:static"],
"lint:style": "phpcs",
"lint:static": "phpstan analyse --memory-limit=1024M",
"fix": ["@fix:style"],
"fix:style": "phpcbf",
"pest": "pest"
},
"autoload": {
Expand Down
Loading
Loading