<mobile> & <desktop> special tag support
173349
private static function mustache(string $out, array $input)
    {
        foreach ($input as $key=>$value) {
            $out = str::replace(sprintf('{{{'.$key.'}}}'), $value, $out);
        }
        return $out;
    }
370680
def add_tag(
            self,
            tag):
        

        if tag.replace("@", "") in self.tags:
            return

        self.refresh
        oldContent = self.to_string(indentLevel=1)
        self.tags += [tag.replace("@", "")]
        newContent = self.to_string(indentLevel=1)

        # ADD DIRECTLY TO CONTENT IF THE PROJECT IS BEING ADDED SPECIFICALLY TO
        # THIS OBJECT
        self.parent._update_document_tree(
            oldContent=oldContent,
            newContent=newContent
        )

        self.refresh
        return None
401004
def marvcli_tag(ctx, add, remove, datasets):
    """"""
    if not any([add, remove]) or not datasets:
        click.echo(ctx.get_help())
        ctx.exit(1)

    app = create_app()
    setids = parse_setids(datasets)
    app.site.tag(setids, add, remove)
994237
def __render_tag(info, state):
    
    new_contexts, context_match = get_tag_context(info['tag_key'], state)
    replacement = ''

    if context_match or context_match == 0:
        replacement = context_match
    elif info['tag_key'] == '.':
        replacement = state.context()
    else:
        replacement = ''

    # Call all callables / methods / lambdas / functions
    if replacement and callable(replacement):
        replacement = make_unicode(replacement())

        state.push_tags(state.default_tags)
        replacement = __render(template=replacement, state=state)
        state.pop_tags()

    for i in xrange(new_contexts): state.context.pop()

    if state.escape():
        return html_escape(replacement)
    return replacement
1059978
def fix_location_tag(dom):
    
    location = dom.match(
        "mods:mods",
        "mods:location",
    )

    # if no location tag found, there is nothing to be fixed
    if not location:
        return
    location = first(location)

    # fix only <mods:location> containing <mods:physicalLocation> tags
    if not location.find("mods:physicalLocation"):
        return

    url = location.find("mods:url", {"usage": "primary display"})

    # parse URL
    if url:
        url = first(url).getContent()
    else:
        urls = filter(
            lambda x: x.getContent(),
            location.find("mods:url")
        )

        if not urls:
            return

        url_tag = max(urls, key=lambda x: len(x.getContent()))
        url = url_tag.getContent()

    # replace the code with new tag
    replacer = dhtmlparser.parseString("""
  <mods:location>
    <mods:holdingSimple>
      <mods:copyInformation>
        <mods:electronicLocator>""" + url + """</mods:electronicLocator>
      </mods:copyInformation>
    </mods:holdingSimple>
  </mods:location>
    """)

    location.replaceWith(
        first(replacer.find("mods:location"))
    )

    dhtmlparser.makeDoubleLinked(dom)
1237361
function moveNestedTags(i) {
  var this$1 = this;

  each(Object.keys(this.tags), function (tagName) {
    moveChildTag.apply(this$1.tags[tagName], [tagName, i]);
  });
}
178733
def add_tag(self, resource_type, resource_id, tag, **_params):
        """"""
        return self.put(self.tag_path % (resource_type, resource_id, tag))
1040280
def temporary_tag(tag):
    
    if tag:
        CTX.repo.tag(tag)
    try:
        yield
    finally:
        if tag:
            CTX.repo.remove_tag(tag)
1239297
function getImmediateCustomParentTag(tag) {
  var ptag = tag;
  while (ptag.__.isAnonymous) {
    if (!ptag.parent) { break }
    ptag = ptag.parent;
  }
  return ptag
}
978350
def tagged(*tags: Tags) -> Callable:
    global GREENSIM_TAG_ATTRIBUTE
    
    def hook(event: Callable):
        def wrapper(*args, **kwargs):
            event(*args, **kwargs)
        setattr(wrapper, GREENSIM_TAG_ATTRIBUTE, tags)
        return wrapper
    return hook
170787
def render_tag(self, context, caller, **kwargs):
        ''''''
        # load configuration from passed options
        self.load_configuration(**kwargs)

        # get request from context
        request = context['request']

        # get full path from request
        self.full_path = request.get_full_path()

        # render content of extension
        content = caller()

        # check content for "active" urls
        content = render_content(
            content,
            full_path=self.full_path,
            parent_tag=self.parent_tag,
            css_class=self.css_class,
            menu=self.menu,
            ignore_params=self.ignore_params,
        )

        return content
1268719
def _indexable_tags(self):
        """"""
        tags = current_app.extensions.get("tags")
        if not tags or not tags.supports_taggings(self):
            return ""

        default_ns = tags.entity_default_ns(self)
        return [t for t in tags.entity_tags(self) if t.ns == default_ns]
174028
def inclusion_tag(self, name, context_class=Context, takes_context=False):
        
        def tag_decorator(tag_func):

            @wraps(tag_func)
            def tag_wrapper(parser, token):

                class InclusionTagNode(template.Node):

                    def render(self, context):
                        if not getattr(self, "nodelist", False):
                            try:
                                request = context["request"]
                            except KeyError:
                                t = get_template(name)
                            else:
                                ts = templates_for_device(request, name)
                                t = select_template(ts)

                            self.template = t
                        parts = [template.Variable(part).resolve(context)
                                 for part in token.split_contents()[1:]]
                        if takes_context:
                            parts.insert(0, context)
                        result = tag_func(*parts)
                        autoescape = context.autoescape
                        context = context_class(result, autoescape=autoescape)
                        return self.template.render(context)

                return InclusionTagNode()
            return self.tag(tag_wrapper)
        return tag_decorator
1195307
def tag(*tags):
    '''
    
    '''
    def dfn(fn):
        _tags = getattr(fn, 'tags', set())
        _tags.update(tags)
        fn.tags = _tags
        return fn
    return dfn
1178047
private Tag getTag(Element node, Tag... tags) {
        String name = node.getTagName();
        String error = null;
        
        try {
            Tag tag = Tag.valueOf(name.toUpperCase());
            int i = ArrayUtils.indexOf(tags, tag);

            if (i < 0) {
                error = "Tag '%s' is not valid at this location";
            } else {
                if (!tag.allowMultiple) {
                    tags[i] = null;
                }

                return tag;
            }
        } catch (IllegalArgumentException e) {
            error = "Unrecognized tag '%s' in layout";
        }

        throw new IllegalArgumentException(getInvalidTagError(error, name, tags));
    }
909792
def tag(self, tag):
        
        url = '%s/tags/%s' % (self, tag)
        response = self.http.get(url, auth=self.auth)
        response.raise_for_status()
        return response.json()
138776
function setDivTag(image, img) {
  var setElemStyle = DOM.setStyle(image.element);
  setElemStyle('backgroundImage', 'url(' + img.src + ')');

  if (image.preserveAspectRatio) {
    var w, h;

    if (image.knownDimensions) {
      w = image.knownDimensions[0];
      h = image.knownDimensions[1];
    } else {
      w = img.width;
      h = img.height;
    }

    setElemStyle('backgroundSize', 'cover');

    if (image.isFlexible) {
      setElemStyle('paddingBottom', ((h / w) * 100.0) + '%');
    } else {
      setElemStyle('width', w + 'px');
      setElemStyle('height', h + 'px');
    }
  }
}