-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from bumpcore/45-compiling-php-templates-from-…
…blade-workflow view compiling
- Loading branch information
Showing
46 changed files
with
311 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
use Illuminate\Contracts\View\ViewCompilationException; | ||
use Illuminate\Filesystem\Filesystem; | ||
use Illuminate\View\Compilers\BladeCompiler; | ||
|
||
require __DIR__ . '/../../vendor/autoload.php'; | ||
|
||
class Compiler extends BladeCompiler | ||
{ | ||
protected function compileForeach($expression) | ||
{ | ||
preg_match('/\( *(.+) +as +(.*)\)$/is', $expression ?? '', $matches); | ||
|
||
if (count($matches) === 0) | ||
{ | ||
throw new ViewCompilationException('Malformed @foreach statement.'); | ||
} | ||
|
||
$iteratee = trim($matches[1]); | ||
|
||
$iteration = trim($matches[2]); | ||
|
||
return "<?php foreach({$iteratee} as {$iteration}): ?>"; | ||
} | ||
|
||
protected function compileEndforeach() | ||
{ | ||
return '<?php endforeach; ?>'; | ||
} | ||
} | ||
|
||
$compiler = new Compiler(new Filesystem(), __DIR__, false); | ||
|
||
foreach (['bootstrap-five', 'tailwind'] as $framework) | ||
{ | ||
foreach (scandir(__DIR__ . '/../../resources/views/' . $framework) as $template) | ||
{ | ||
if (!str_ends_with($template, '.blade.php')) | ||
{ | ||
continue; | ||
} | ||
|
||
$bladePath = __DIR__ . '/../../resources/views/' . $framework . '/' . $template; | ||
$compiledPath = __DIR__ . '/../../resources/php/' . $framework . '/' . str_replace('.blade.php', '.php', $template); | ||
|
||
file_put_contents( | ||
$compiledPath, | ||
$compiler->compileString(file_get_contents($bladePath)) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
name: Fix syling | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- "*.x" | ||
paths: | ||
- "**.php" | ||
push: | ||
branches: | ||
- master | ||
- "*.x" | ||
paths: | ||
- "**.php" | ||
|
||
pull_request: | ||
paths: | ||
- "**.php" | ||
pull_request: | ||
paths: | ||
- "**.php" | ||
|
||
permissions: | ||
contents: write | ||
contents: write | ||
jobs: | ||
php-cs-fixer: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
php-cs-fixer: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
|
||
- name: Install dependencies | ||
run: composer install | ||
- name: Install dependencies | ||
run: composer install | ||
|
||
- name: Execute php-cs-fixer | ||
run: ./vendor/bin/php-cs-fixer fix | ||
- name: Execute php-cs-fixer | ||
run: ./vendor/bin/php-cs-fixer fix | ||
|
||
- uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: Fix styling | ||
- uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: Fix styling |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: View Compiling | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- "*.x" | ||
paths: | ||
- "**.php" | ||
|
||
pull_request: | ||
paths: | ||
- "**.php" | ||
|
||
permissions: | ||
contents: write | ||
jobs: | ||
run: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
|
||
- name: Install dependencies | ||
run: composer install | ||
|
||
- name: Execute script | ||
run: php .github/scripts/compile-templates.php | ||
|
||
- uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: Compiling Templates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<div class="p-4 bg-light rounded mb-3"> | ||
<div class="overflow-x-auto w-full bg-white rounded p-3"> | ||
<pre><?= $data('code'); ?></pre> | ||
<pre><?php echo $data('code'); ?></pre> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,25 @@ | ||
<?php switch($data('level')): case 1: ?> | ||
<h1 class="fw-bold mb-3"><?= $data('text'); ?></h1> | ||
<?php break; | ||
<?php switch($data('level')): | ||
case (1): ?> | ||
<h1 class="fw-bold mb-3"><?php echo $data('text'); ?></h1> | ||
<?php break; ?> | ||
|
||
case 2: ?> | ||
<h2 class="fw-bold mb-3"><?= $data('text'); ?></h2> | ||
<?php break; | ||
<?php case (2): ?> | ||
<h2 class="fw-bold mb-3"><?php echo $data('text'); ?></h2> | ||
<?php break; ?> | ||
|
||
case 3: ?> | ||
<h3 class="fw-bold mb-3"><?= $data('text'); ?></h3> | ||
<?php break; | ||
<?php case (3): ?> | ||
<h3 class="fw-bold mb-3"><?php echo $data('text'); ?></h3> | ||
<?php break; ?> | ||
|
||
case 4: ?> | ||
<h4 class="fw-semibold mb-3"><?= $data('text'); ?></h4> | ||
<?php break; | ||
<?php case (4): ?> | ||
<h4 class="fw-semibold mb-3"><?php echo $data('text'); ?></h4> | ||
<?php break; ?> | ||
|
||
case 5: ?> | ||
<h5 class="fw-semibold mb-3"><?= $data('text'); ?></h5> | ||
<?php break; | ||
<?php case (5): ?> | ||
<h5 class="fw-semibold mb-3"><?php echo $data('text'); ?></h5> | ||
<?php break; ?> | ||
|
||
case 6: ?> | ||
<h6 class="fw-semibold mb-1"><?= $data('text'); ?></h6> | ||
<?php break; ?> | ||
<?php case (6): ?> | ||
<h6 class="fw-semibold mb-1"><?php echo $data('text'); ?></h6> | ||
<?php break; ?> | ||
<?php endswitch; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<img | ||
alt="<?= $data('caption'); ?>" | ||
src="<?= $data('file.url'); ?>" | ||
alt="<?php echo $data('caption'); ?>" | ||
src="<?php echo $data('file.url'); ?>" | ||
class="d-block mb-3 w-100 rounded" | ||
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
<div class="bg-light d-flex mb-3 rounded overflow-hidden flex-column flex-sm-row"> | ||
<img | ||
alt="<?= $data('meta.title'); ?>" | ||
alt="<?php echo $data('meta.title'); ?>" | ||
width="100%" | ||
src="<?= $data('meta.image.url'); ?>" | ||
src="<?php echo $data('meta.image.url'); ?>" | ||
style="object-fit: cover" | ||
> | ||
<div class="m-4 p-4 bg-white rounded flex-2"> | ||
<h4 class="text-xl fw-semibold"><?= $data('meta.title'); ?></h4> | ||
<h4 class="text-xl fw-semibold"><?php echo $data('meta.title'); ?></h4> | ||
<p class="mb-3 text-sm"> | ||
<small> | ||
<a | ||
class="link-dark fw-bold" | ||
href="<?= $data('link'); ?>" | ||
href="<?php echo $data('link'); ?>" | ||
target="_blank" | ||
><?= $data('link'); ?></a> | ||
><?php echo $data('link'); ?></a> | ||
</small> | ||
</p> | ||
<p class="mb-0"><?= $data('meta.description'); ?></p> | ||
<p class="mb-0"><?php echo $data('meta.description'); ?></p> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
<?php if ($data('style') === 'ordered'): ?> | ||
<?php if($data('style') === 'ordered'): ?> | ||
<ol class="mb-3"> | ||
<?php foreach ($data('items', []) as $item): ?> | ||
<li class="mb-1"><?= $item; ?></li> | ||
<?php endforeach; ?> | ||
<?php foreach($data('items', []) as $item): ?> | ||
<li class="mb-1"><?php echo $item; ?></li> | ||
<?php endforeach; ?> | ||
</ol> | ||
<?php else: ?> | ||
<ul class="mb-3"> | ||
<?php foreach ($data('items', []) as $item): ?> | ||
<li class="mb-1"><?= $item; ?></li> | ||
<?php endforeach; ?> | ||
<?php foreach($data('items', []) as $item): ?> | ||
<li class="mb-1"><?php echo $item; ?></li> | ||
<?php endforeach; ?> | ||
</ul> | ||
<?php endif; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<p class="mb-3"><?= $data('text'); ?></p> | ||
<p class="mb-3"><?php echo $data('text'); ?></p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
<div class="bg-light d-flex mb-3 rounded overflow-hidden flex-column flex-sm-row"> | ||
<img | ||
alt="<?= $data('name'); ?>" | ||
src="<?= $data('photo'); ?>" | ||
alt="<?php echo $data('name'); ?>" | ||
src="<?php echo $data('photo'); ?>" | ||
style="object-fit: cover" | ||
width="100%" | ||
> | ||
<div class="m-4 p-4 bg-white rounded flex-2"> | ||
<h4 class="text-xl fw-semibold"><?= $data('name'); ?></h4> | ||
<h4 class="text-xl fw-semibold"><?php echo $data('name'); ?></h4> | ||
<p class="mb-3 text-sm"> | ||
<small> | ||
<a | ||
class="link-dark fw-bold" | ||
href="<?= $data('link'); ?>" | ||
href="<?php echo $data('link'); ?>" | ||
target="_blank" | ||
><?= $data('link'); ?></a> | ||
><?php echo $data('link'); ?></a> | ||
</small> | ||
</p> | ||
<p class="mb-0"><?= $data('description'); ?></p> | ||
<p class="mb-0"><?php echo $data('description'); ?></p> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.