We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suppose, we've got a template:
$template = <<<TEMPLATE <div class="list"> %s [[list-item]] %s [[logo]] <div class="logo"> %s </div> [[/logo]] [[text]]<div class="text">%s</div>[[/text]] [[img]]<img src="%s" alt=""/>[[/img]] [[/list-item]] </div> TEMPLATE;
Sometimes it's getting hard to maintain such expressions as
$data = [ [ [ 'tag' => 'list-item', 'content' => [ [ [ 'tag' => 'logo', 'content' => [ [ [ 'tag' => 'img', 'content' => 'localhost//image1.jpg' ], ] ] ], [ 'tag' => 'text', 'content' => 'TEXT1' ], ] ], ], ], ];
The text was updated successfully, but these errors were encountered:
Obviously, more readable approach would be like this:
$img = TemplaterClient::getElement( tag: 'img' ); $img->append( 'localhost//image1.jpg' ); $logo = TemplaterClient::getElement( tag: 'logo' ); $logo->append( $img ); $text = TemplaterClient::getElement( tag: 'text' ); $text->append( 'TEXT1' ); $element = TemplaterClient::getElement(); $element->append( $logo ); $element->append( $text ); /* * The elements' number added into $list_item, equals the modifiers' number in the list-item tag. */ $list_item = TemplaterClient::getElement( 'list-item' ); $list_item->append( $element ); /** * The elements' number inside of $elements equals the top level modifiers number in the template. */ $elements = TemplaterClient::getElement(); $elements->append( $list_item ); $templater = new Templater(); $result = $templater->render( $template, $elements );
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Suppose, we've got a template:
Sometimes it's getting hard to maintain such expressions as
The text was updated successfully, but these errors were encountered: