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
18 changes: 17 additions & 1 deletion sage/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ In turn, the class might look like this:
namespace App\View\Components;

use Roots\Acorn\View\Component;
use Illuminate\View\View;

class ExampleComponent extends Component
{
Expand All @@ -79,10 +80,25 @@ class ExampleComponent extends Component
if (!is_numeric($this->imageId)) {
return false;
}

return wp_get_attachment_image($this->imageId, 'medium_large');
}

/**
* Get the view / contents that represent the component.
*/
public function render(): View
{
return view('components.example-component');
// or a view string:
// return <<<'blade'
// <div>
// <strong>Hello World!</strong>
// </div>
// blade;
}
}

```

## Argument and attribute names
Expand Down