-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
901 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Empty file.
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,16 @@ | ||
<?php $this->layout('main', ['foo' => 'Bar!']) ?> | ||
|
||
<?php $this->section('one') ?> | ||
World <?= $this->foo ?> | ||
<?php $this->stop() ?> | ||
|
||
<?php $this->section('two') ?> | ||
I Win | ||
<?php $this->replace() ?> | ||
|
||
Buffalo Bill | ||
|
||
<?php $this->section('three') ?> | ||
MAN | ||
<?php | ||
$this->stop(); |
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 @@ | ||
<?= $T->foo ?> |
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,2 @@ | ||
<?php | ||
echo implode('|', $this->data()); |
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,11 @@ | ||
<?php $this->block('spaceless') ?> | ||
<?php $this->block('wrap', '<div>', '</div>') ?> | ||
<?php $this->block('spaceless') ?> | ||
<ul> | ||
<?php $this->block('repeat', 3) ?> | ||
<li>a</li> | ||
<?php $this->endblock('repeat'); ?> | ||
</ul> | ||
<?php $this->endblock('spaceless') ?> | ||
<?php $this->endblock('wrap') ?> | ||
<?php $this->endblock('spaceless') ?> |
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 @@ | ||
I have 2 extensions |
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,2 @@ | ||
<?php | ||
echo implode(',', $this->data()); |
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,14 @@ | ||
<?php $this->section('one') ?> | ||
Hello <?= $this->foo.' ' ?> | ||
<?php $this->stop() ?> | ||
|
||
Alone | ||
|
||
<?php $this->section('two') ?> | ||
NO | ||
<?php $this->stop() ?> | ||
|
||
<?php $this->section('three') ?> | ||
YES | ||
<?php | ||
$this->stop(); |
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,49 @@ | ||
<?php namespace Foil\Tests; | ||
|
||
use JsonSerializable; | ||
|
||
class Value | ||
{ | ||
public $value; | ||
|
||
public function __construct($value) | ||
{ | ||
$this->value = $value; | ||
} | ||
} | ||
|
||
class ToArray extends Value | ||
{ | ||
public function toArray() | ||
{ | ||
return ['toarray' => (array) $this->value]; | ||
} | ||
} | ||
|
||
class AsArray extends Value | ||
{ | ||
public function asArray() | ||
{ | ||
return ['asarray' => (array) $this->value]; | ||
} | ||
} | ||
|
||
class Json implements JsonSerializable | ||
{ | ||
public function jsonSerialize() | ||
{ | ||
return '<b>I am JSON</b>'; | ||
} | ||
} | ||
|
||
class Target extends Value | ||
{ | ||
} | ||
|
||
class Transformer | ||
{ | ||
public function transform($object) | ||
{ | ||
return is_object($object) ? ['transformed' => get_object_vars($object)] : false; | ||
} | ||
} |
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,113 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Foil is Awesome!</title> | ||
<meta name="description" content=""> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
</head> | ||
<body> | ||
|
||
<div> | ||
<ul> | ||
<li><a href="http://www.example.com">First Item</a></li> | ||
<li><a href="#">Second Item</a></li> | ||
</ul> | ||
</div> | ||
|
||
<div> | ||
|
||
<p>Deep var test: Lorem Ipsum Dolor</p> | ||
|
||
<p>Default test: I am a default.</p> | ||
|
||
<p>__get test: TEST ME!</p> | ||
|
||
<p>Raw test: <strong>This is a strong tag html content</strong></p> | ||
|
||
<p>Autoescape test: <strong>This is a strong tag html content</strong></p> | ||
|
||
<p>Filter test: I AM LOWERCASE</p> | ||
|
||
<p>Advanced test: HELLO WORLD!</p> | ||
|
||
</div> | ||
|
||
<div> | ||
Here something for you. | ||
</div> | ||
|
||
<div> | ||
<p>OVERRIDE a section defined in a PARTIAL</p> | ||
|
||
<p> | ||
I am a partial. And this: "TEST ME!" is a var I share with template, but | ||
this "I am a partial var!" is a specific partial var. | ||
</p> | ||
|
||
</div> | ||
|
||
<div> | ||
<p> | ||
I am another partial. | ||
This: "I am a partial var too." is a specific partial var. | ||
This: "TEST ME!" is a var I share with template. | ||
A shared var skipped: "Foil is Awesome!". | ||
</p> | ||
</div> | ||
|
||
<div> | ||
<p>Should BE SUPPLYED by layout.</p> | ||
</div> | ||
|
||
<div> | ||
I am here. | ||
</div> | ||
|
||
<div> | ||
|
||
<p>MAIN LAYOUT, first section</p> | ||
|
||
<div> | ||
|
||
<p>Should REPLACE layout first-child layout section.</p> | ||
|
||
</div> | ||
|
||
<p>MAIN LAYOUT, first section after child</p> | ||
|
||
<p>Should BE APPENDED to layout first section.</p> | ||
|
||
</div> | ||
|
||
<div> | ||
|
||
<p>Should REPLACE layout second section.</p> | ||
|
||
<div> | ||
<p>Extended layout third section.</p> | ||
<p>Should BE APPENDED to extended layout third section.</p> | ||
</div> | ||
|
||
</div> | ||
|
||
<div> | ||
|
||
<p>EXTENDED LAYOUT, Out of any section, output a deep var Another deep var.</p> | ||
|
||
<div> | ||
|
||
<p> | ||
I am another partial. | ||
This: "!!!" is a specific partial var. | ||
This: "TEST ME!" is a var I share with template. | ||
A shared var skipped: "". | ||
</p> | ||
|
||
<p>FINAL TEMPLATE, Out of any section, ouput a var TEST ME!</p> | ||
|
||
</div> | ||
</div> | ||
|
||
</body> | ||
</html> |
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,33 @@ | ||
<?php $this->layout('layout') ?> | ||
|
||
<p>EXTENDED LAYOUT, Out of any section, output a deep var <?= $this->v('a.var.in.extended') ?></p> | ||
|
||
<?php $this->section('first') ?> | ||
|
||
<p>Should BE APPENDED to layout first section.</p> | ||
|
||
<?php $this->append() // first ?> | ||
|
||
<?php $this->section('first-child') ?> | ||
|
||
<p>Should REPLACE layout first-child layout section.</p> | ||
|
||
<?php $this->replace() // first-child ?> | ||
|
||
<?php $this->section('second') ?> | ||
|
||
<p>Should REPLACE layout second section.</p> | ||
|
||
<div> | ||
|
||
<?php $this->section('third') ?> | ||
<p>Extended layout third section.</p> | ||
<?php $this->append() // third ?> | ||
|
||
</div> | ||
|
||
<?php $this->replace(); // second ?> | ||
|
||
<div> | ||
<?= $this->buffer() ?> | ||
</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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php $this->layout('extended') ?> | ||
|
||
<?php $this->section('a-section') ?> | ||
|
||
<p>Should BE SUPPLYED by layout.</p> | ||
|
||
<?php $this->stop() ?> | ||
|
||
|
||
<?php $this->section('third') ?> | ||
|
||
<p>Should BE APPENDED to extended layout third section.</p> | ||
|
||
<?php $this->append() // third ?> | ||
|
||
|
||
<?php $this->section('another-section') ?> | ||
|
||
<p>OVERRIDE a section defined in a PARTIAL</p> | ||
|
||
<?php $this->replace() // another-section ?> | ||
|
||
<?= $this->insert('partials/partial-2', ['a_partial_var' => '"!!!"'], ['test_me']) ?> | ||
|
||
<p>FINAL TEMPLATE, Out of any section, ouput a var <?= $this->v('test_me') ?></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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title><?= $this->v('title', 'Default Title') ?></title> | ||
<meta name="description" content=""> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
</head> | ||
<body> | ||
|
||
<?= $this->ww('menu', '<div><ul>%s</ul></div>', '<li><a href="%s">%s</a></li>') ?> | ||
|
||
<?= $this->wwif('menu', false, '<div>%s</div>', '<li><a href="%s">%s</a></li>') ?> | ||
|
||
<div> | ||
|
||
<p>Deep var test: <?= $this->v('a.pretty.deep.var') ?></p> | ||
|
||
<p>Default test: <?= $this->v('i_do_not_exist', 'I am a default.') ?></p> | ||
|
||
<p>__get test: <?= $this->test_me ?></p> | ||
|
||
<p>Raw test: <?= $this->raw('html_content') ?></p> | ||
|
||
<p>Autoescape test: <?= $this->html_content ?></p> | ||
|
||
<p>Filter test: <?= $this->f('uppercase|reverse', 'lowercase') ?></p> | ||
|
||
<p>Advanced test: <?= $this->v('a.var.0|uppercase|reverse') ?></p> | ||
|
||
</div> | ||
|
||
<div> | ||
<?= $this->returnSomething() ?> | ||
</div> | ||
|
||
<div> | ||
<?= $this->insert('partials/partial', ['a_partial_var' => '"I am a partial var!"']) ?> | ||
</div> | ||
|
||
<div> | ||
<?= $this->raw('i_do_not_exist', $this->insert('partials/partial-2', ['a_partial_var' => '"I am a partial var too."'])) ?> | ||
</div> | ||
|
||
<div> | ||
<?= $this->supply('a-section') ?> | ||
</div> | ||
|
||
<div> | ||
<?= $this->supply('a-non-existent-section', 'I am here.') ?> | ||
</div> | ||
|
||
<div> | ||
|
||
<?php $this->section('first') ?> | ||
|
||
<p>MAIN LAYOUT, first section</p> | ||
|
||
<div> | ||
|
||
<?php $this->section('first-child') ?> | ||
|
||
<p>MAIN LAYOUT, first child section</p> | ||
|
||
<?php $this->stop() // first-child ?> | ||
|
||
</div> | ||
|
||
<p>MAIN LAYOUT, first section after child</p> | ||
|
||
<?php $this->stop() // first ?> | ||
|
||
</div> | ||
|
||
<div> | ||
|
||
<?php $this->section('second') ?> | ||
|
||
<p>MAIN LAYOUT, second section</p> | ||
|
||
<?php $this->stop() // second ?> | ||
|
||
</div> | ||
|
||
<div> | ||
<?= $this->buffer() ?> | ||
</div> | ||
|
||
</body> | ||
</html> |
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,6 @@ | ||
<p> | ||
I am another partial. | ||
This: <?= $this->v('a_partial_var') ?> is a specific partial var. | ||
This: "<?= $this->test_me ?>" is a var I share with template. | ||
A shared var skipped: "<?= $this->v('title') ?>". | ||
</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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php $this->section('another-section') ?> | ||
|
||
<p>A SECTION defined in a PARTIAL</p> | ||
|
||
<?php $this->stop() ?> | ||
|
||
<p> | ||
I am a partial. And this: "<?= $this->test_me ?>" is a var I share with template, but | ||
this <?= $this->v('a_partial_var') ?> is a specific partial var. | ||
</p> |
Oops, something went wrong.