Skip to content

Commit

Permalink
fix: remove the whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
papac committed Dec 20, 2024
1 parent c3b4b0e commit 5808058
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/Lexique/CompileCustomDirective.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ trait CompileCustomDirective
*/
protected function compileCustomDirective(string $expression): string
{
$collection = [];
preg_match_all($this->getCustomDirectivePartern(), $expression, $matches);

array_shift($matches);

$replaces = [];
$values = $matches[0] ?? [];
$names = $matches[1] ?? [];
Expand Down
10 changes: 2 additions & 8 deletions src/Lexique/CompileRawPhp.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ trait CompileRawPhp
*/
protected function compileRawPhp(string $expression): string
{
// $expression = trim($expression);

foreach (['Raw', 'EndRaw'] as $token) {
$out = $this->{'compile' . $token}($expression);

Expand All @@ -33,10 +31,8 @@ protected function compileRawPhp(string $expression): string
*/
protected function compileRaw(string $expression): string
{
// $expression = trim($expression);

$output = preg_replace_callback(
'/\%raw/',
'/\%(raw|php)/',
function ($match) {
array_shift($match);

Expand All @@ -56,10 +52,8 @@ function ($match) {
*/
protected function compileEndRaw(string $expression): string
{
// $expression = trim($expression);

$output = preg_replace_callback(
'/\%endraw/',
'/\%(endraw|endphp)/',
function ($match) {
array_shift($match);

Expand Down
21 changes: 10 additions & 11 deletions src/MacroManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,43 +31,42 @@ public function __construct(Tintin $tintin)
*/
public function make(string $template): string
{
$__template = $template;
$loader = $this->tintin->getLoader();

if (is_null($loader)) {
return $this->tintin->renderString($__template);
return $this->tintin->renderString($template);
}

if (!$loader->exists($__template)) {
$loader->failLoading($__template . ' macro is not found');
if (!$loader->exists($template)) {
$loader->failLoading($template . ' macro is not found');
}

$__tintin = $this->tintin;

/**
* Load template when is not a cached file
*/
if (!$loader->isExpired($__template)) {
require $loader->getCacheFileResolvedPath($__template);
if (!$loader->isExpired($template)) {
require $loader->getCacheFileResolvedPath($template);
}

/**
* Put the template into cache
*/
$content = $loader->getFileContent($__template);
$content = $loader->getFileContent($template);

$this->tintin->getCompiler()->compileMacroExtraction($content);
$containers = $this->tintin->getCompiler()->getMacroContainers();
$result = '';

foreach ($containers as $name => $container) {
$result .= $this->makeTheMocra($name, $container["parameters"], $container["content"]);
$result .= $this->makeMacro($name, $container["parameters"], $container["content"]);
}

$result = "<?php\n\n" . $result;
$loader->cache($__template, $result);
$loader->cache($template, $result);

require $loader->getCacheFileResolvedPath($__template);
require $loader->getCacheFileResolvedPath($template);
return "";
}

Expand All @@ -79,7 +78,7 @@ public function make(string $template): string
* @param string $content
* @return string
*/
private function makeTheMocra(
private function makeMacro(
string $function,
array $parameters,
string $content
Expand Down
1 change: 1 addition & 0 deletions src/StackManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public function getStack(string $name, ?string $default = null)
if (is_null($this->pushes[$name])) {
$this->pushes[$name] = $default ?? '';
}

return $this->tintin->renderString(
$this->pushes[$name],
['__tintin' => $this->tintin]
Expand Down

0 comments on commit 5808058

Please sign in to comment.