title: Pyramid - Is it possible to render my mako template as a string within my view callable?
body: <p>I have a view callable that does looks similar to:</p>
  
  <pre><code>def post_comment(request):
      """ Posts the users comment to the thread """
  
      try:
          new_comment = comments.post()
      except InvalidComment as e:
          return {'success' : False, 'message' : e.message}
  
      # need to do something like:
      new_comment = pyramid.template.render(new_comment)
  
      return {'success' : True, 'message' : new_comment}
  </code></pre>
  
  <p>The route config for this view callable is:</p>
  
  <pre><code>config.add_route('post_comment',
                   '/comments/{link_id}/post',
                   view='site.views.post_comment',
                   view_renderer='json')
  </code></pre>
  
  <p>Using this, I can AJAXify my comment submissions and have a shiny web 2.0 website. The problem is, I'd like to render <code>new_comment</code> through my mako template to build the HTML and return that. However, I can't find a way to do this.</p>
  
  <p>How can I render a mako template within my view callable to return the HTML as a JSON response?</p>