format_string should be ``app_label model counts``
    
    renders 'tagging_ext/tag_autocomplete_js.html
11226
def tag_autocomplete_js(format_string=None):
    """"""
    if format_string:
        context_list = format_string.split(' ')
        context = {
            'app_label':context_list[0],'model':context_list[1], 'counts':context_list[2]
        }
    else:
        context = {}
    return render_to_string('tagging_ext/tagging_autocomplete_js.html', context)
1247759
def _format_tag(self, name, value, scraper_config):
        
        return '%s:%s' % (scraper_config['labels_mapper'].get(name, name), value)
923471
function routeTags(tag, content, indentStr, indentLevel) {
    if (COMPONENT.test(tag)) {
        return jxh(content, indentStr, indentLevel);
    } else {
        let attrs = getType(content)==='object' ? getAttributes(content) : '';
        switch (getType(content)) {
            case 'null':
            case 'undefined':
            case 'NaN':
            case 'string':
            case 'number':
            case 'boolean':
                return renderElement(tag, attrs, content, indentStr, indentLevel);
                break;
            case 'array':
                return parseArray(tag, attrs, content, indentStr, indentLevel);
                break;
            case 'object':
                return parseObject(tag, attrs, content, indentStr, indentLevel);
                break;
            default:
                objTypeError(content);
                break;
        }
    }
}
801107
function(value, attr, minLength, model) {
        if (!_.isString(value) || value.length < minLength) {
          return this.format(getMessageKey(this.msgKey, defaultMessages.minLength), this.formatLabel(attr, model), minLength);
        }
      }
518647
function(value, attr, minValue, model) {
        if (!isNumber(value) || value < minValue) {
          return this.format(defaultMessages.min, this.formatLabel(attr, model), minValue);
        }
      }
1253490
def generic_ref_formatter(view, context, model, name, lazy=False):
    
    try:
        if lazy:
            rel_model = getattr(model, name).fetch()
        else:
            rel_model = getattr(model, name)
    except (mongoengine.DoesNotExist, AttributeError) as e:
        # custom_field_type_formatters seems to fix the issue of stale references
        # crashing pages, since it intercepts the display of all ReferenceField's.
        return Markup(
            '<span class="label label-danger">Error</span> <small>%s</small>' % e
        )

    if rel_model is None:
        return ''

    try:
        return Markup(
            '<a href="%s">%s</a>'
            % (
                url_for(
                    # Flask-Admin creates URL's namespaced w/ model class name, lowercase.
                    '%s.details_view' % rel_model.__class__.__name__.lower(),
                    id=rel_model.id,
                ),
                rel_model,
            )
        )
    except werkzeug.routing.BuildError as e:
        return Markup(
            '<span class="label label-danger">Error</span> <small>%s</small>' % e
        )
1002489
def tag( params )

            # TODO: make these method args if possible
            tag   = params['tag']
            attr  = params['attr']
            cdata = params['cdata']

            unless attr.kind_of?( HTML::AutoAttr )
                attr = HTML::AutoAttr.new( attr, @sorted )
            end

            # emtpy tag
            unless cdata and cdata.to_s.length
                return ( @indent * @level ) + '<' + tag + attr.to_s + ' />' + @newline
            end

            rendered  = ''
            no_indent = 0

            if cdata.kind_of?( Array )

                if cdata[0].kind_of?( Hash )
                    @level += 1
                    rendered = @newline

                    cdata.each do |hash|
                        rendered += tag( hash )
                    end
                    @level -= 1
                else
                    str = ''
                    cdata.each do |scalar|
                        str += tag( 'tag' => tag, 'attr' => attr, 'cdata' => scalar )
                    end
                    return str
                end

            elsif cdata.kind_of?( Hash )
                @level += 1
                rendered = @newline + tag( cdata )
                @level -= 1

            else
                rendered = @encode ? @encoder.encode( cdata, @encodes ) : cdata
                no_indent = 1
            end

            return (@indent * @level)  \
                + '<' + tag + attr.to_s + '>'  \
                + rendered.to_s + ( no_indent == 1 ? '' : ( @indent * @level ) )  \
                + '</' + tag + '>' + @newline

        end
103557
def format_label(self, field, counter):
        
        return '<label for="id_formfield_%s" %s>%s</label>' % (
            counter, field.field.required and 'class="required"', field.label)
334241
function(params, callback) {
      var t = this;
      if (typeof(params) !== 'string' || params.length < 1) {
        callback("Autocomplete paramter must be a nonzero string");
      }

      // Forward to the completion mechanism if it can be completed
      if (params.substr(-1).match(/([0-9])|([a-z])|([A-Z])|([_])/)) {
        t.repl.complete(params, callback);
      } else {
        // Return a no-op autocomplete
        callback(null, [[],'']);
      }
    }
1143209
def method_missing(name, *args, &block)
      if @type.has_attribute?(name.to_s)
        __attribute__(name, *args)
      else
        __tag__(name, *args, &block)
      end
    end
1329056
def count_tags(self):
    ''''''
    for key, model in TAGGED.items():
        collection = '{0}_tags'.format(key)
        results = (model.objects(tags__exists=True)
                        .map_reduce(map_tags, reduce_tags, collection))
        for result in results:
            tag, created = Tag.objects.get_or_create(name=result.key,
                                                     auto_save=False)
            tag.counts[key] = int(result.value) if result.value else 0
            tag.save()
526626
function label (tagType, count) {
  const icon = tagType ? dom.create('i')
    .class(`qm-changelog-icon-${tagType} qm-changelog-text-${tagType}`)
    .attr('title', tags.displayName[tagType]) : undefined

  return dom.create('div').class(`qm-changelog-label qm-changelog-label-${tagType}`)
    .add(icon)
    .add(dom.create('span').text(count))
}
520823
function htmlToComponent(str, tags, opts) {
  var keys = objectKeys(tags);
  var props = opts.props || {};
  var preserveAttributes = opts.preserveAttributes || [];
  var tagAttributes = [];
  var reactTags={};
  var reactKeys=[];
  var key;
  for(var i = 0; i<keys.length; i++) {
    key = "AB"+Math.random().toString(36).substring(2);
    if(typeof tags[keys[i]] !== "function") {
      if(typeof tags[keys[i]].slice !== "function") continue;
      tagAttributes = tags[keys[i]].slice(0,-1);
      reactTags[key] = tags[keys[i]].slice(-1)[0];
    }
    else
      reactTags[key] = tags[keys[i]];

    reactKeys.push(key);

    str = str
      .replace(new RegExp("(<\/?)"+keys[i]+"(?:[^>\"']|\".*\"|'.*')*>", "ig"), function(match, start){
        // find/replace spell-save attributes within tag to restore capitals
        if(start !== "</")
          for(var a=0; a<tagAttributes.length; a++)
            match = replaceAttribute(match, tagAttributes[a], tagAttributes[a]);

        // replace key
        return match
          .replace(new RegExp(start+keys[i]+"(\\s|>)", "i"), start+key+"$1");
      });
  }

  // remove/disable html comments
  str = str.replace(/<!--|-->/g,"")

  // find/replace global spell-save attributes to restore capitals
  var attributes = preserveReactAttributes.concat(preserveAttributes);
  for(var i=0; i<attributes.length; i++) 
    str = replaceAttribute(str, attributes[i], attributes[i]);
 
  var jsx = htmlToJsx(str);

  // replace props variables {key} with corrected variables {props['key']}
  for(var key in props) {
    jsx = jsx
      .replace(new RegExp("(\{"+key+"\})","g"),"{props['"+key+"']}");
  }
  
  var component = ReactTransform(jsx).code;
  
  // replace component variables (ComponentName) with corrected variables (tags['ComponentName'])
  for(var i=0; i<reactKeys.length; i++) {
    component = component
      .replace(new RegExp(reactKeys[i],"g"), "reactTags['"+reactKeys[i]+"']"); 
  }

  return eval(component);
}
1065221
def render(self, name, value, attrs=None, multi=False, renderer=None):
        
        DJANGO_111_OR_UP = (VERSION[0] == 1 and VERSION[1] >= 11) or (
            VERSION[0] >= 2
        )
        if DJANGO_111_OR_UP:
            return super(DynamicRawIDWidget, self).render(
                name, value, attrs, renderer=renderer
            )

        if attrs is None:
            attrs = {}

        related_url = reverse(
            'admin:{0}_{1}_changelist'.format(
                self.rel.to._meta.app_label,
                self.rel.to._meta.object_name.lower(),
            ),
            current_app=self.admin_site.name,
        )

        params = self.url_parameters()
        if params:
            url = u'?' + u'&'.join(
                [u'{0}={1}'.format(k, v) for k, v in params.items()]
            )
        else:
            url = u''
        if "class" not in attrs:
            attrs[
                'class'
            ] = (
                'vForeignKeyRawIdAdminField'
            )  # The JavaScript looks for this hook.
        app_name = self.rel.to._meta.app_label.strip()
        model_name = self.rel.to._meta.object_name.lower().strip()
        hidden_input = super(widgets.ForeignKeyRawIdWidget, self).render(
            name, value, attrs
        )

        extra_context = {
            'hidden_input': hidden_input,
            'name': name,
            'app_name': app_name,
            'model_name': model_name,
            'related_url': related_url,
            'url': url,
        }
        return render_to_string(
            'dynamic_raw_id/admin/widgets/dynamic_raw_id_field.html',
            extra_context,
        )
780995
def render_app_label(context, app, fallback=""):
    
    try:
        text = app['app_label']
    except KeyError:
        text = fallback
    except TypeError:
        text = app
    return text
824653
def describe_form(label, fields):
    
    try:
        app_name, model_name = label.split('.')[-2:]
    except (IndexError, ValueError):
        raise CommandError("Need application and model name in the form: appname.model")
    model = apps.get_model(app_name, model_name)

    opts = model._meta
    field_list = []
    for f in opts.fields + opts.many_to_many:
        if not f.editable:
            continue
        if fields and f.name not in fields:
            continue
        formfield = f.formfield()
        if '__dict__' not in dir(formfield):
            continue
        attrs = {}
        valid_fields = ['required', 'initial', 'max_length', 'min_length', 'max_value', 'min_value', 'max_digits', 'decimal_places', 'choices', 'help_text', 'label']
        for k, v in formfield.__dict__.items():
            if k in valid_fields and v is not None:
                # ignore defaults, to minimize verbosity
                if k == 'required' and v:
                    continue
                if k == 'help_text' and not v:
                    continue
                if k == 'widget':
                    attrs[k] = v.__class__
                elif k in ['help_text', 'label']:
                    attrs[k] = str(force_text(v).strip())
                else:
                    attrs[k] = v

        params = ', '.join(['%s=%r' % (k, v) for k, v in sorted(attrs.items())])
        field_list.append('    %(field_name)s = forms.%(field_type)s(%(params)s)' % {
            'field_name': f.name,
            'field_type': formfield.__class__.__name__,
            'params': params
        })
    return '''
from django import forms
from %(app_name)s.models import %(object_name)s

class %(object_name)sForm(forms.Form):
%(field_list)s
''' % {'app_name': app_name, 'object_name': opts.object_name, 'field_list': '\n'.join(field_list)}
216709
def _tag(val, tag):
        """"""
        if isinstance(val, str):
            val = bytes(val, 'utf-8')
        return (bytes('<' + tag + '>', 'utf-8') + val +
                bytes('</' + tag + '>', 'utf-8'))