You’re messing with the search result page and figure you need a new zone on the page for some cool web parts.
Being an avid SharePoint Designer fan as I am, you open up the site and copy _catalogs/masterpage/SearchResults.aspx to _catalogs/masterpage/SearchResults_custom.aspx. Then you add a new web part zone to the bottom of the page and save the layout.
Next you make the layout available on your site (Bing it) and create a new page based on the layout.
Boom! – Code blocks are not allowed
Turns out the fix is pretty easy as the file actually has code blocks in it.
Simply remove the <% %> parts which does conditional checks for the Ribbon being hidden if the user is in Browser mode (not Design, Catalog or Edit mode)
You can probably implement the check yourself in JSOM if needed, or simply show/hide the ribbon in all modes.
So, how come the default layout works with code blocks? Well.. SharePoint does whatever it wants with the default pages and can configure SharePoint to work as it pleases. Being an outsider you don’t have those powers.