(self, context)
Render the node.
Render the node.
Render the node .
def render(self, context):  # pylint: disable=g-bad-name
    """Render the node."""

    explicit_import_text = self._nodelist.render(context)

    # Look for an importManager on the element.  If we find one:
    # - scan the import text for import statements
    # - add each to the manager
    # - get the complete import set
    import_lists = None
    try:
      import_manager = django_template.Variable(
          '%s.importManager' % self._element).resolve(context)
      import_regex = _GetFromContext(context, _IMPORT_REGEX)
      for line in explicit_import_text.split('\n'):
        match_obj = re.match(import_regex, line)
        if match_obj:
          import_manager.AddImport(match_obj.group('import'))
      import_lists = import_manager.ImportLists()
    except django_template.base.VariableDoesNotExist:
      pass

    import_template = _GetFromContext(context, _IMPORT_TEMPLATE)
    if import_lists:
      ret_lists = []
      for import_list in import_lists:
        ret_lists.append(
            '\n'.join([import_template % x for x in import_list]))
      # Each import should be on its own line and each group of imports should
      # be separated by a new line.
      return '\n\n'.join([ret_list for ret_list in ret_lists if ret_list])
    else:
      # We could not find the import lists from an import manager, revert to
      # the original text
      return explicit_import_text.strip()
def render ( self , context ) : # pylint: disable=g-bad-name explicit_import_text = self . _nodelist . render ( context ) # Look for an importManager on the element.  If we find one: # - scan the import text for import statements # - add each to the manager # - get the complete import set import_lists = None try : import_manager = django_template . Variable ( '%s.importManager' % self . _element ) . resolve ( context ) import_regex = _GetFromContext ( context , _IMPORT_REGEX ) for line in explicit_import_text . split ( '\n' ) : match_obj = re . match ( import_regex , line ) if match_obj : import_manager . AddImport ( match_obj . group ( 'import' ) ) import_lists = import_manager . ImportLists ( ) except django_template . base . VariableDoesNotExist : pass import_template = _GetFromContext ( context , _IMPORT_TEMPLATE ) if import_lists : ret_lists = [ ] for import_list in import_lists : ret_lists . append ( '\n' . join ( [ import_template % x for x in import_list ] ) ) # Each import should be on its own line and each group of imports should # be separated by a new line. return '\n\n' . join ( [ ret_list for ret_list in ret_lists if ret_list ] ) else : # We could not find the import lists from an import manager, revert to # the original text return explicit_import_text . strip ( )