-
Notifications
You must be signed in to change notification settings - Fork 0
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
7 changed files
with
89 additions
and
13 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
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% if props.template %} | ||
{% set parts = props.template|split(':') %} | ||
{% if parts|length == 2 %} | ||
{% set templateMode = parts[0] %} | ||
{% set template = parts[1] %} | ||
{% else %} | ||
{% set templateMode = 'site' %} | ||
{% set template = parts[0] %} | ||
{% endif %} | ||
{{ craft.app.getView().renderTemplate(template, _context|merge(component.getContext()), templateMode)|raw }} | ||
{% 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
use markhuot\craftpest\factories\Entry; | ||
use markhuot\craftpest\web\TestableResponse; | ||
use markhuot\keystone\models\Component; | ||
|
||
use function markhuot\craftpest\helpers\test\dd; | ||
|
||
it('renders template component', function () { | ||
$component = Component::factory()->type('keystone/template')->create(); | ||
$component->data->merge(['template' => 'basic-template'])->save(); | ||
|
||
expect(trim($component->render()))->toBe('foo'); | ||
}); | ||
|
||
it('renders entry links', function () { | ||
$entry = Entry::factory()->create(); | ||
|
||
$entryComponent = Component::factory()->type('keystone/entry')->create(); | ||
$entryComponent->data->merge(['entry' => [$entry->id]])->save(); | ||
|
||
$templateComponent = Component::factory()->type('keystone/template')->path($entryComponent->id)->create(); | ||
$templateComponent->data->merge(['template' => 'cp:keystone/entry/link'])->save(); | ||
|
||
$html = $entryComponent->render(); | ||
expect((new TestableResponse(['content' => $html]))->querySelector('a')) | ||
->getNodeOrNodes(fn ($node) => $node->getNode(0)->getAttribute('href'))->toBe($entry->uri) | ||
->getText()->toBe($entry->title); | ||
}); |
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 @@ | ||
foo |