0

I have a blade component which can be used in blade files.

<x-my-component :inputOne="Hello" : inputTwo="Hi again"></x-my-component>

And for legacy reasons I would like to compile/translate it into html string so I could be used like that

$htmlComponentCode = Blade::compileComponent(
    '<x-my-component :inputOne="Hello" : inputTwo="Hi again"></x-my-component>'
);

echo htmlComponentCode ;

And by echoing it out it will display the component same as it was included in a blade file.

I'm aware of this solution:

$html = (new MyComponent("Hello", "Hi again"))->render();

But I would prefer the on with html name.

Is something like that possible?

1

1 Answer 1

1

Since this question is inactive for quite some time I will close it concluding there is probably no better solution than

$html = (new MyComponent("Hello", "Hi again"))->render();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.