For those that seem to like the idea of shorter comments, I whipped up
this piece of middleware for your projects.  It's my first attempt at
middleware so the code might seem a bit immature for you advanced
djangoers out there.  I opted to use the {# #} syntax, but that can
easily be changed in the regular expressions below.

#################################################
### The Middleware
#################################################
import re
regx_extractComments = re.compile('(\{\#.*?\#\})', re.DOTALL)

class NewCommentMiddleware:
        def process_response(self, request, response):
                if response.has_header and response.headers.get("Content-Type",
"")[0:9] == "text/html":
                        response.content = regx_extractComments.sub( "", 
response.content)
                return response

###################################################
## For the TextMate Django Bundle.  Add following to `HTML (Django)`
###################################################

                {       name = 'comment.block.django.template';
                        begin = '{#';
                        end = '#}';
                },

Reply via email to