Skip to content
New issue

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

x-component tag example #49

Closed
jreviews opened this issue May 20, 2020 · 8 comments
Closed

x-component tag example #49

jreviews opened this issue May 20, 2020 · 8 comments

Comments

@jreviews
Copy link

I put together a demo using this package that allows using the x-component tag syntax in template files.

https://github.com/clickfwd/blade-standalone-component-tags

Would love some feedback on whether this is a good approach or if someone has a better way to do it.

@jreviews
Copy link
Author

Ok, I just realized this doesn't work with anonymous components. Those with just a view template file and no associated class. Does someone know how to get those working?

@ryangjchandler
Copy link

Ok, I just realized this doesn't work with anonymous components. Those with just a view template file and no associated class. Does someone know how to get those working?

The same way that you create an alias for the class based components - instead of passing a class, pass the name of a view.

@jreviews
Copy link
Author

@ryangjchandler Thanks, but do you have this working? I get the following error:

GET / - Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Foundation\Application] is not instantiable. in /../blade/vendor/illuminate/container/Container.php:1011

This seems to be tightly coupled with the Laravel application in ComponentTagCompiler.

I did manage to get it working in the end, but not using the blade class in this repo.

I had to create a fake version of the Illuminate\Contracts\Foundation\Application class and pass that as the 3rd parameter to my own version of the Blade implements FactoryContract class and then map some classes in the container to make them load my versions.

It's all very convoluted, but everything works now.

@ryangjchandler
Copy link

ryangjchandler commented Jun 15, 2020

Yeah, it's slightly annoying that it's tightly bound to the Laravel Foundation\Application class.

If would be nice if this library included an Application class that implemented those required APIs.

@lexdubyna
Copy link

@jreviews Could you please share your convoluted solution where everything works?

@jreviews
Copy link
Author

jreviews commented Dec 3, 2020

@lexdubyna I don't have it anymore, but this repo has a working example https://github.com/clickfwd/yoyo-blade-app

You can see how to use it here https://github.com/clickfwd/yoyo-blade-app/blob/master/app/bootloader.php

Ignore all the Yoyo stuff and use $blade->render to render your layout.

@lexdubyna
Copy link

@jreviews Thank you very much! Your solution works great!

@lexdubyna
Copy link

#57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants