
from __future__ import (
    absolute_import, division, print_function, unicode_literals
)

from klein.plating import Plating
from twisted.web.template import tags, slot

from klein.test.test_resource import requestMock, _render
from klein.test.util import TestCase
from klein import Klein

plating = Plating(
    defaults=dict(
        title="JUST A TITLE",
        content="NEVER MIND THE CONTENT",
    ),
    tags=tags.html(
        tags.head(tags.title(slot("title"))),
        tags.body(
            tags.h1(slot("title")),
            tags.div(slot("content"),
                     Class="content")
        )
    ),
)


class PlatingTests(TestCase):
    """
    Tests for L{Plating}.
    """

    def setUp(self):
        """
        Create an app and a resource wrapping that app for this test.
        """
        self.app = Klein()
        self.kr = self.app.resource()

    def test_template(self):
        """
        Rendering a L{Plating.content} decorated route results in stuff.
        """

        @self.app.route("/")
        @plating.content(tags.span(slot("ok")))
        def plateMe(request):
            return {"ok": "test-data-present"}

        request = requestMock(b"/")
        d = _render(self.kr, request)
        self.successResultOf(d)
        self.assertIn(b'<span>test-data-present</span>',
                      request.getWrittenData())

@@ -996,25 +996,24 @@
         %22%22%22%0A
-%0A
         @sel
@@ -1009,16 +1009,31 @@
        @
+plating.routed(
 self.app
@@ -1039,24 +1039,25 @@
 p.route(%22/%22)
+,
 %0A        @pl
@@ -1057,25 +1057,24 @@
     
-@plating.content(
+                
 tags

change the interface so plating knows about route