Skip to content

Commit

Permalink
fix: echo
Browse files Browse the repository at this point in the history
  • Loading branch information
papac committed Dec 18, 2024
1 parent 6de5339 commit 0ea298c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"license": "MIT",
"keywords": ["Tintin", "View Engine", "Php Template", "Franck DAKIA", "common mark", "Bow Markdown", "bow-Markdown", "Papac"],
"require": {
"php": "^8.1"
"php": "^8.1",
"bowphp/framework": "^5.1"
},
"authors": [
{
Expand All @@ -18,7 +19,7 @@
}
},
"require-dev": {
"phpunit/phpunit": "^8",
"phpunit/phpunit": "^9",
"squizlabs/php_codesniffer": "3.*",
"laravel/framework": "^8.0",
"spatie/phpunit-snapshot-assertions": "^4.2"
Expand Down
2 changes: 1 addition & 1 deletion src/Lexique/CompileEchos.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function compileEcho(string $expression): string
return $value;
}

return '<?php echo htmlspecialchars(' . $match[1] . ', ENT_QUOTES); ?>';
return '<?php echo e(' . $match[1] . '); ?>';
}, $expression);

return $output == $expression ? '' : $output;
Expand Down
2 changes: 1 addition & 1 deletion tests/CompileEchoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function testCompileEcho()

$render = $compileEcho->invoke($this->compiler, '{{ "hello world" }}');

$this->assertEquals($render, '<?php echo htmlspecialchars("hello world", ENT_QUOTES); ?>');
$this->assertEquals($render, '<?php echo e("hello world"); ?>');
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/__snapshots__/CompileIfTest__testBlockStatement__1.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php if ($age > 16): ?>
<?php echo htmlspecialchars("You can drive !", ENT_QUOTES); ?>
<?php echo e("You can drive !"); ?>
<?php elseif ($name > 15 ): ?>
<?php echo htmlspecialchars("You can drive next year !", ENT_QUOTES); ?>
<?php echo e("You can drive next year !"); ?>
<?php else: ?>
<?php echo htmlspecialchars("You can\'t drive", ENT_QUOTES); ?>
<?php echo e("You can\'t drive"); ?>
<?php endif; ?>

0 comments on commit 0ea298c

Please sign in to comment.