Search code examples
laravel-livewire

How in placeholder function of HTML block call library method?


Making rendering placeholder on Laravel / Livewire site as written here: https://livewire.laravel.com/docs/lazy#rendering-placeholder-html

I try to use my library method :

public function placeholder()
{
    return <<<'HTML'
    <div>
        ' . LibraryFacade::getProcessingCode() . '
    </div>
    HTML;
}

But that does not not and I see my php code on the text.

Which way is correct?

  "livewire/livewire": "^3.4.6",,
 "laravel/framework": "^10.45.1",
 "tailwindcss": "^3.4.1",

Solution

  • In the example on the Livewire website the PHP nowdoc syntax is used (here the reference). If you have your own class::method to generate the placeholder you can simply return its output:

    public function placeholder()
    {
       return LibraryFacade::getProcessingCode();
    }