Skip to content

Instantly share code, notes, and snippets.

@bastianallgeier
Last active July 12, 2017 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bastianallgeier/a8ff0b6cee56b36d3aa2b616e8ad981b to your computer and use it in GitHub Desktop.
Save bastianallgeier/a8ff0b6cee56b36d3aa2b616e8ad981b to your computer and use it in GitHub Desktop.
<?php
return [
'props' => [
'title' => [
'type' => 'field',
'required' => true,
],
'links' => [
'type' => 'structure',
'required' => true
],
'modifier' => [
'type' => 'string',
'default' => 'Example--dark',
'validator => function($value) {
return v::in($value, ['Example--dark', 'Example--light']);
}
]
]
]
<div class="ExamplePattern <?= $modifier ?>">
<h2><?= $title->html() ?></h2>
<ul>
<?php foreach ($links as $link) ?>
<li><a href="<?= $link->url() ?>"><?= $link->text() ?></a></li>
<?php endforeach ?>
</ul>
</div>
<?php
class ExamplePatternTest extends TestCase
{
protected $fixtures = __DIR__ . '/_fixtures';
public function testExample()
{
$page = page('some-page/from/fixtures');
$dom = $this->patternDom('example-pattern', [
'title' => $page->title(),
'links' => $page->links()
'modifier' => 'Example--light',
]);
}
}
<?php snippet('header') ?>
<?php pattern('example-pattern', [
'title' => $page->title(),
'links' => $page->links()
'modifier' => 'Example--light',
]) ?>
<?php snippet('footer') ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment