Skip to content

Commit

Permalink
Merge pull request #6 from hokoo/v3.0
Browse files Browse the repository at this point in the history
v3.0
  • Loading branch information
hokoo authored Aug 26, 2024
2 parents 3f6083e + aed0969 commit 01a97ac
Show file tree
Hide file tree
Showing 12 changed files with 2,242 additions and 132 deletions.
1 change: 1 addition & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PHP_VERSION=8.3
27 changes: 27 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: PHP Tests

on: [ push, pull_request, workflow_dispatch ]

jobs:
phpunit:
name: ${{ matrix.php-version }}
runs-on: ubuntu-latest

strategy:
matrix:
php-version: [ 7.4, 8.0, 8.1, 8.2, 8.3 ]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}

- name: Install dependencies
run: composer install --no-progress --no-suggest --prefer-dist

- name: Run tests
run: vendor/bin/phpunit
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.idea/
/vendor/
.phpunit.result.cache
.env
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# iTRON Templater
[![PHPUnit Tests](https://github.com/hokoo/templater/actions/workflows/phpunit.yml/badge.svg)](https://github.com/hokoo/templater/actions/workflows/phpunit.yml)

HTML Templater for PHP.

Stop using the Twig. It's too painful and meaningless. We do not need to reinvent the wheel and get a new dialect above PHP. We need to make it better.
Expand Down Expand Up @@ -208,3 +210,26 @@ In fact, it does not matter what order you describe the tags. The next template
</form>
[[/form]]
```

### Modifier with predefined values

Predefined modifier can only accept an integer value as index (starting from 0) of one of the predefined values. Any invalid value will be considered as 0.

```php
$tpl = <<<TEMPLATE
<div class="classname">
[[value1|value2|value3/]]%d
</div>
TEMPLATE;

$result = $templater->render( $tpl, [
1,
] );
```

The result will be:
```html
<div class="classname">
value2
</div>
```
128 changes: 0 additions & 128 deletions Templater.php

This file was deleted.

11 changes: 7 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
}
],
"autoload": {
"files": [
"Templater.php"
]
"psr-4": {
"iTRON\\Templater\\": "src/"
}
},
"require-dev": {
"phpunit/phpunit": "^9.6"
}
}
}
Loading

0 comments on commit 01a97ac

Please sign in to comment.