Skip to content
Open
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
16 changes: 13 additions & 3 deletions app/Parsers/InlineHtmlParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected function doEchoParse(BaseNode $node, $prefix, $content)
}

$range->start->line += $this->startLine + $node->position->startLine - 2;
$range->end->line += $this->startLine + $node->position->startLine - 2;
$range->end->line += $this->startLine + $node->position->startLine - 2;

return $range;
};
Expand Down Expand Up @@ -124,13 +124,19 @@ protected function parseLiteralNode(LiteralNode $node)

protected function parseBladeDirective(DirectiveNode $node)
{
if ($node->isClosingDirective || !$node->hasArguments()) {
$content = $node->toString();

if (!$node->hasArguments()) {
$content .= "('";
}

if ($node->isClosingDirective) {
return;
}

$methodUsed = '@' . $node->content;
$safetyPrefix = 'directive';
$snippet = "<?php\n" . str_repeat(' ', $node->getStartIndentationLevel()) . str_replace($methodUsed, $safetyPrefix . $node->content, $node->toString() . ';');
$snippet = "<?php\n" . str_repeat(' ', $node->getStartIndentationLevel()) . str_replace($methodUsed, $safetyPrefix . $node->content, $content . ';');

$sourceFile = (new Parser)->parseSourceFile($snippet);

Expand All @@ -148,6 +154,10 @@ protected function parseBladeDirective(DirectiveNode $node)

$result = Parse::parse($sourceFile);

if (count($result->children) === 0) {
return;
}

$child = $result->children[0];

$child->methodName = '@' . substr($child->methodName, mb_strlen($safetyPrefix));
Expand Down