htmlburger / wpemerge

A modern, MVC-powered WordPress as a CMS workflow. 🚀
https://wpemerge.com/
GNU General Public License v2.0
453 stars 38 forks source link

Feature request: app_partial function that returns instead of echoes #7

Closed VesterDe closed 6 years ago

VesterDe commented 6 years ago

Would it be against the general design of this framework to make a new function (let's say) app_partial_s, which is exactly the same as app_partial, but returns the output of the composed View, instead of echoing it?

I want to handle shortcodes within wpemerge, and app_partial can't work in that situation, since it echoes.

I can write the PR, if it's approved.

Edit: To clarify, I can wrap ob_start() around it, but I'd rather not.

atanas-dev commented 6 years ago

It's not really needed - app_partial() is an echo-ing shortcut so you can just use what it uses internally: https://github.com/htmlburger/wpemerge/blob/master/src/functions.php#L79-L83 i.e. this is what you need:

$html = View::make( $views )->with( $context )->toString();
VesterDe commented 6 years ago

Yeah ok, I saw that, I guess that also an ok option.

Thanks.