Closed khalyomede closed 1 year ago
Hi there, I have no desire/plans to create custom node types for each individual directive.
You are free to use the existing collection helper methods to retrieve all section
directives from the template:
<?php
use Stillat\BladeParser\Document\Document;
$template = <<<'BLADE'
@section ('title')
@section ('title2')
BLADE;
$doc = Document::fromText($template);
$sections = $doc->getDirectives()
->where('content', 'section');
Regarding the parameters, similarly this is not something I am planning on supporting at the moment (since it would require including a heavy dependency, as well as not cover scenarios where user's are supplying JSON content to directives). Please see our earlier discussion on ways to do this: https://github.com/Stillat/blade-parser/discussions/12
@khalyomede
Also just a reminder about the arguments getValues()
method that was added previously to help with this 🙂:
Currently
@section()
is aDirectiveNode
I have to manually get the
DirectiveNode::sourceContent
property and work with itI would have expected to have a
SectionNode
so I could get all node of that type usingAnd to be able to have all their parameters
My goal is to be able to get translations out of the second parameter (if there is any) for my package at https://github.com/khalyomede/laravel-translate from this kind of blade code:
To be able to pull
List of books
and add it on the[lang].json
file if not added yet