Skip to content

Commit

Permalink
snippet wip
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Nov 1, 2023
1 parent 0729ede commit 8a6a26c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Application/UI/Control.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function redrawControl(?string $snippet = null, bool $redraw = true): voi
$this->invalidSnippets = [];

} else {
$this->invalidSnippets[$snippet] = false;
unset($this->invalidSnippets[$snippet]);
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/Bridges/ApplicationLatte/Nodes/ControlNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,14 @@ public function print(PrintContext $context): string
$this->name,
);

$fetchCode .= $tag->closestTag(['snippetArea']) && !$tag->closestTag(['snippet'])
? 'if ($ʟ_tmp instanceof Nette\Application\UI\Renderable) $ʟ_tmp->snippetMode = $this->global->uiControl->snippetMode;'
: 'if ($ʟ_tmp instanceof Nette\Application\UI\Renderable) $ʟ_tmp->redrawControl(null, $ʟ_tmp->snippetMode = false);';

if ($this->escape) {
return $context->format(
<<<'XX'
%raw
if ($ʟ_tmp instanceof Nette\Application\UI\Renderable) $ʟ_tmp->redrawControl(null, false);
ob_start(fn() => '');
$ʟ_tmp->%raw(%args) %line;
$ʟ_fi = new LR\FilterInfo(%dump); echo %modifyContent(ob_get_clean());
Expand All @@ -117,7 +120,6 @@ public function print(PrintContext $context): string
return $context->format(
<<<'XX'
%raw
if ($ʟ_tmp instanceof Nette\Application\UI\Renderable) $ʟ_tmp->redrawControl(null, false);
$ʟ_tmp->%raw(%args) %line;


Expand Down
5 changes: 3 additions & 2 deletions src/Bridges/ApplicationLatte/SnippetRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function renderSnippets(array $blocks, array $params): bool
}

$this->renderingSnippets = true;
$this->control->snippetMode = false;
//$this->control->snippetMode = false;
foreach ($blocks as $name => $block) {
if (!$this->control->isControlInvalid($name)) {
continue;
Expand All @@ -117,7 +117,8 @@ public function renderSnippets(array $blocks, array $params): bool
$function($params);
}

$this->control->snippetMode = true;
$this->control->redrawControl(null, false);
//$this->control->snippetMode = true;
$this->renderChildren();
return true;
}
Expand Down

0 comments on commit 8a6a26c

Please sign in to comment.