For some kind of output filter, I need to access the final rendered output string that includes both view data as well as 'hardcoded' text in the view file.
For example:
welcome.blade.php
<div>This is bad and you are {{ $variable }}</div>
controller, composer, or something else that attaches variables
view()->with('variable', 'bad')
The final output would be
<div>This is bad and you are bad</div>
But now let's pretend we want to replace each instance of 'bad' with 'good', so we get:
<div>This is good and you are good</div>
Altering view data is well supported, but how to apply some altering logic to the fully rendered content? (since I think this is the only way to also alter contents of a view file itself?)
Note: if and only if possible, I'd prefer a 'hook-in' solution instead of an 'extend-core' one..
Take a look at the CompilerEngine (Illuminate\View\Engines\CompilerEngine). You could use it to get the evaluated contents of a view by using the get method. Maybe combine that with a registered ServiceProvider to manipulate the views content. Also check out the BladeCompiler maybe you can combine those.
But trying to change hardcoded text seems a bit odd. Why not just use variables in the first place. I mean why is it hardcoded if you want to change it afterwards?