Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "newtron/core",
"version": "0.1.0",
"version": "0.1.1",
"type": "library",
"description": "Core framework package for Newtron",
"homepage": "https://github.com/newtron-framework/core",
Expand Down
5 changes: 5 additions & 0 deletions src/Quark/QuarkCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ private function registerBuiltinDirectives(): void {
return "\$__quark->endSlot();\n";
};

$this->directives['include'] = function ($args) {
$template = trim($args, '"\'');
return "echo \$__quark->render('{$template}');\n";
};

$this->directives['if'] = fn($args) => "if ({$args}) {\n";
$this->directives['elseif'] = fn($args) => "} elseif ({$args}) {\n";
$this->directives['else'] = fn($args) => "} else {\n";
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Document/DocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function testGetSingleMeta(): void {
);
}

public function testSetOG(): void {
public function testSetOg(): void {
App::create($this->testRootPath);

$document = App::getDocument();
Expand All @@ -96,7 +96,7 @@ public function testSetOG(): void {
$this->assertEquals(['og:test' => 'test_og'], $document->getOG());
}

public function testGetAllOG(): void {
public function testGetAllOg(): void {
App::create($this->testRootPath);

$document = App::getDocument();
Expand All @@ -109,7 +109,7 @@ public function testGetAllOG(): void {
);
}

public function testGetSingleOG(): void {
public function testGetSingleOg(): void {
App::create($this->testRootPath);

$document = App::getDocument();
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/Http/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function testGetCookies(): void {
$this->assertEquals('test_value', $request->getCookie('test-cookie'));
}

public function testGetURI(): void {
public function testGetUri(): void {
$_SERVER['REQUEST_URI'] = '/test?param=value';
$request = new Request();

Expand All @@ -63,7 +63,7 @@ public function testGetPath(): void {
$this->assertEquals('/test', $request->getPath());
}

public function testGetURL(): void {
public function testGetUrl(): void {
$_SERVER['HTTPS'] = 'on';
$_SERVER['HTTP_HOST'] = 'test.com';
$_SERVER['REQUEST_URI'] = '/test?param=value';
Expand Down Expand Up @@ -118,13 +118,13 @@ public function testIsAjax(): void {
$this->assertTrue($request->isAjax());
}

public function testGetZeroIPWhenNotSet(): void {
public function testGetZeroIpWhenNotSet(): void {
$request = new Request();

$this->assertEquals('0.0.0.0', $request->getIP());
}

public function testGetIP(): void {
public function testGetIp(): void {
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$request = new Request();

Expand Down
1 change: 1 addition & 0 deletions tests/Unit/Quark/QuarkCompilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function testBuiltinDirectivesRegistered(): void {
'outlet',
'slot',
'endslot',
'include',
'if',
'elseif',
'else',
Expand Down
10 changes: 10 additions & 0 deletions tests/Unit/Quark/QuarkEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ public function testRenderTemplateWithCustomOutlet(): void {
);
}

public function testRenderTemplateWithInclude(): void {
$this->createTestTemplate('test', '<div>{% include included %}</div>');
$this->createTestTemplate('included', '<p>Included</p>');

$this->assertEquals(
'<div><p>Included</p></div>',
$this->engine->render('test')
);
}

public function testRenderTemplateWithIf(): void {
$this->createTestTemplate('test', '<div>{% if $test %}True{% endif %}</div>');

Expand Down