title: Django 1.4 custom template tag return HTML
body: <p>I set up a working custom template tag, it is registered, I can call it, it instantiates a template.Node instance and calls its render() method. The problem is that when I return a simple string like</p>
  
  <pre><code>def render(self, context):
      return 'asd'
  </code></pre>
  
  <p>it works ok, but it fails whenever i try to return something containing html:</p>
  
  <pre><code>def render(self, context):
      return mark_safe('&lt;ul class="jqueryFileTree" style="display: none;"&gt;&lt;li&gt;&lt;ITEM&lt;/li&gt;&lt;/ul&gt;')
  </code></pre>
  
  <p>it fails silently without rendering a thing. Any help?</p>
  
  <p><strong>EDIT</strong>: added mark_safe. Still doesn't work</p>
  
  <p><strong>EDIT</strong>: the tag:</p>
  
  <pre><code>    import os
      import urllib
  
      from django import template
      from django.utils.safestring import mark_safe
  
      register = template.Library()
  
      class DirTree(template.Node):
          def __init__(self, start_dir):
              self.start_dir = start_dir
          def render(self, context):
              # CODE THAT GENERATES A HTML NESTED LIST
              return mark_safe('&lt;ul class="jqueryFileTree"&gt;&lt;li&gt;&lt;ITEM&lt;/li&gt;&lt;/ul&gt;')
  
      @register.tag
      def print_tree(parser, token):
          try:
              # split_contents() knows not to split quoted strings.
              tag_name, start_dir = token.split_contents()
          except ValueError:
              raise template.TemplateSyntaxError("%r tag requires a single argument" % token.contents.split()[0])
          if not (start_dir[0] == start_dir[-1] and start_dir[0] in ('"', "'")):
              raise template.TemplateSyntaxError("%r tag's argument should be in quotes" % tag_name)
          return DirTree(start_dir[1:-1])
  
  
  
  # TEMPLATE.HTML
  # HTML 'N STUFF
      &lt;div id="file-tree"&gt;
          {% print_tree "catflow_portal/static/repo/usr/test-user/catalogs/food/" %}
      &lt;/div&gt;
  #END TAGS
  </code></pre>