I have an application that does this; shows the same content from a view but sometimes as an AJAX request or as a full page.

I have a 'default' template in my layouts folder that has all the page HTML markup for a full page and an 'ajax' template that just contains {{ content() }} and nothing else. I have a BaseController that all my other controllers inherit.

This is not what is actually in my code as it's a bit long winded for me. If you would like more code elegance than this you could use a variable that controls the template used. At the top of my BaseController I have: