How to create a component outside of a view file

I’m looking to use the paginate_links function and would like to include a custom icon for the previous and next links.

I’ve tried following the advice here:

But I get an error “Undefined variable: attributes”. I’ve tried the following:

view('components.icon', ['icon' => 'chevron-left'])

$icon = new Icon('chevron-left');
return $icon->render();

What is the correct way to retrieve a component with fully formed HTML?

Are you using sage-svg for icons in Sage?

I do have sage-svg installed but the Icon component doesn’t use it at the moment. Though if there’s a solution using sage svg then I’m definitely open to using it!

Yes, IMHO this is already tested and leverages all the Sage features, you should use this instead.

Thanks @strarsis it does fix the issue. I still think it would be good to know how to include a component outside of a blade file though.

Well, that error indicates that there is no variable attributes, but the blade template that is included as a view tries to use it.