How to completely disable Diazo on a specific path

I'm working on an (inherited) website that uses Plone and BackboneJS to offer a streamlined search interface over a catalog of items.

My task was to apply a new Diazo theme, which worked great for the rest of the website, except for this search page. The items inserted by the Backbone app would be all garbled and wrong. In the end, I managed to isolate the problem to a single page template that would load only that SPA, and the problem still persisted, (on my development machine), while the same code ran ok on the production server.

So what was the difference? The development machine had a Diazo theme active. As soon as I've disabled the Diazo theme, the problem disappeared. Oh well, time for a <notheme /> I said, but that didn't work either: no rule was applied in the transform. After debugging through plone.transformchain.zpublisher.applyTransform and, I came to the conclusion that the serializer used just "breaks" the HTML. It doesn't break it, it fixes it the problems in that HTML template file, but the fixes break the Underscore templates that will transform that file.

So, my fix is a hack:

from ZODB.POSException import ConflictError
from ZPublisher.interfaces import IPubAfterTraversal
from plone.transformchain.interfaces import DISABLE_TRANSFORM_REQUEST_KEY
from zope.component import adapter
import logging

logger = logging.getLogger('pkg.diazotheme')

def disable_diazo_for_templates(event):
    """ Code modeled after
        request = event.request
        if not ("/spa/template" in request.getURL()):

        if DISABLE_TRANSFORM_REQUEST_KEY not in request.environ:
            request.environ[DISABLE_TRANSFORM_REQUEST_KEY] = True

    except ConflictError:
            "Swallowed exception in pkg.diazotheme "
            "IPubAfterTraversal event handler")

And register this subscriber with:

<subscriber handler=".events.disable_diazo_for_templates" />

But this fix is wrong. My template files came as .html.dtml files placed in a portal_skins layer. The simplest fix would be to just make their content type text/plain. Like, simply renaming them to .txt. With that Content-Type they would be ignored completely by Diazo. Another good way would be (probably) to move them in a static browser resource folder.