当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript StringWrapper.replaceAllMapped方法代码示例

本文整理汇总了TypeScript中angular2/src/facade/lang.StringWrapper.replaceAllMapped方法的典型用法代码示例。如果您正苦于以下问题:TypeScript StringWrapper.replaceAllMapped方法的具体用法?TypeScript StringWrapper.replaceAllMapped怎么用?TypeScript StringWrapper.replaceAllMapped使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在angular2/src/facade/lang.StringWrapper的用法示例。


在下文中一共展示了StringWrapper.replaceAllMapped方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: normalizeCSS

export function normalizeCSS(css: string): string {
  css = StringWrapper.replaceAll(css, RegExpWrapper.create('\\s+'), ' ');
  css = StringWrapper.replaceAll(css, RegExpWrapper.create(':\\s'), ':');
  css = StringWrapper.replaceAll(css, RegExpWrapper.create("\\'"), '"');
  css = StringWrapper.replaceAllMapped(css, RegExpWrapper.create('url\\(\\"(.+)\\"\\)'),
                                       (match) => `url(${match[1]})`);
  css = StringWrapper.replaceAllMapped(css, RegExpWrapper.create('\\[(.+)=([^"\\]]+)\\]'),
                                       (match) => `[${match[1]}="${match[2]}"]`);
  return css;
}
开发者ID:AsherBarak,项目名称:angular,代码行数:10,代码来源:utils.ts

示例2: _applyStrictSelectorScope

 // return a selector with [name] suffix on each simple selector
 // e.g. .foo.bar > .zot becomes .foo[name].bar[name] > .zot[name]
 _applyStrictSelectorScope(selector: string, scopeSelector: string): string {
   var isRe = RegExpWrapper.create('\\[is=([^\\]]*)\\]');
   scopeSelector = StringWrapper.replaceAllMapped(scopeSelector, isRe, (m) => m[1]);
   var splits = [' ', '>', '+', '~'],
     scoped = selector,
     attrName = '[' + scopeSelector + ']';
   for (var i = 0; i < splits.length; i++) {
     var sep = splits[i];
     var parts = scoped.split(sep);
     scoped = ListWrapper.map(parts, function(p) {
       // remove :host since it should be unnecessary
       var t = StringWrapper.replaceAll(p.trim(), _polyfillHostRe, '');
       if (t.length > 0 &&
         !ListWrapper.contains(splits, t) &&
         !StringWrapper.contains(t, attrName)) {
         var re = RegExpWrapper.create('([^:]*)(:*)(.*)');
         var m = RegExpWrapper.firstMatch(re, t);
         if (isPresent(m)) {
           p = m[1] + attrName + m[2] + m[3];
         }
       }
       return p;
     }).join(sep);
   }
   return scoped;
 }
开发者ID:tavwizard,项目名称:angular,代码行数:28,代码来源:shadow_css.ts

示例3: _insertPolyfillRulesInCssText

 _insertPolyfillRulesInCssText(cssText) {
   return StringWrapper.replaceAllMapped(cssText, _cssContentRuleRe, function(m) {
     var rule = m[0];
     rule = StringWrapper.replace(rule, m[1], '');
     rule = StringWrapper.replace(rule, m[2], '');
     return m[3] + rule;
   });
 }
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:8,代码来源:shadow_css.ts

示例4: _insertPolyfillRulesInCssText

 /*
  * Process styles to add rules which will only apply under the polyfill
  *
  * For example, we convert this rule:
  *
  * polyfill-rule {
  *   content: ':host menu-item';
  * ...
  * }
  *
  * to this:
  *
  * scopeName menu-item {...}
  *
 **/
 _insertPolyfillRulesInCssText(cssText: string): string {
   // Difference with webcomponents.js: does not handle comments
   return StringWrapper.replaceAllMapped(cssText, _cssContentRuleRe, function(m) {
     var rule = m[0];
     rule = StringWrapper.replace(rule, m[1], '');
     rule = StringWrapper.replace(rule, m[2], '');
     return m[3] + rule;
   });
 }
开发者ID:188799958,项目名称:angular,代码行数:24,代码来源:shadow_css.ts

示例5: _replaceUrls

 _replaceUrls(cssText, re, baseUrl) {
   return StringWrapper.replaceAllMapped(cssText, re, (m) => {
     var pre = m[1];
     var url = StringWrapper.replaceAll(m[2], _quoteRe, '');
     var post = m[3];
     var resolvedUrl = this._resolver.resolve(baseUrl, url);
     return pre + "'" + resolvedUrl + "'" + post;
   });
 }
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:9,代码来源:style_url_resolver.ts

示例6: escapeString

function escapeString(input: string, re: RegExp): string {
  return StringWrapper.replaceAllMapped(input, re, (match) => {
    if (match[0] == '$') {
      return IS_DART ? '\\$' : '$';
    } else if (match[0] == '\n') {
      return '\\n';
    } else {
      return `\\${match[0]}`;
    }
  });
}
开发者ID:MingXingTeam,项目名称:awesome-front-end,代码行数:11,代码来源:util.ts

示例7: extractStyleUrls

export function extractStyleUrls(resolver: UrlResolver, baseUrl: string,
                                 cssText: string): StyleWithImports {
  var foundUrls = [];
  var modifiedCssText = StringWrapper.replaceAllMapped(cssText, _cssImportRe, (m) => {
    var url = isPresent(m[1]) ? m[1] : m[2];
    if (!isStyleUrlResolvable(url)) {
      // Do not attempt to resolve non-package absolute URLs with URI scheme
      return m[0];
    }
    foundUrls.push(resolver.resolve(baseUrl, url));
    return '';
  });
  return new StyleWithImports(modifiedCssText, foundUrls);
}
开发者ID:0oAimZo0,项目名称:Angular2Learning,代码行数:14,代码来源:style_url_resolver.ts

示例8: _replaceUrls

  _replaceUrls(cssText: string, re: RegExp, baseUrl: string) {
    return StringWrapper.replaceAllMapped(cssText, re, (m) => {
      var pre = m[1];
      var originalUrl = m[2];
      if (RegExpWrapper.test(_dataUrlRe, originalUrl)) {
        // Do not attempt to resolve data: URLs
        return m[0];
      }
      var url = StringWrapper.replaceAll(originalUrl, _quoteRe, '');
      var post = m[3];

      var resolvedUrl = this._resolver.resolve(baseUrl, url);

      return pre + "'" + resolvedUrl + "'" + post;
    });
  }
开发者ID:KenWilliamson,项目名称:Angular2HostedMobileApp,代码行数:16,代码来源:style_url_resolver.ts

示例9: _convertColonRule

 _convertColonRule(cssText: string, regExp: RegExp, partReplacer: Function): string {
   // p1 = :host, p2 = contents of (), p3 rest of rule
   return StringWrapper.replaceAllMapped(cssText, regExp, function(m) {
     if (isPresent(m[2])) {
       var parts = m[2].split(','), r = [];
       for (var i = 0; i < parts.length; i++) {
         var p = parts[i];
         if (isBlank(p)) break;
         p = p.trim();
         ListWrapper.push(r, partReplacer(_polyfillHostNoCombinator, p, m[3]));
       }
       return r.join(',');
     } else {
       return _polyfillHostNoCombinator + m[3];
     }
   });
 }
开发者ID:188799958,项目名称:angular,代码行数:17,代码来源:shadow_css.ts

示例10: getSourceWithImports

 getSourceWithImports(): SourceWithImports {
   var moduleAliases = {};
   var imports: string[][] = [];
   var newSource =
       StringWrapper.replaceAllMapped(this.sourceWithModuleRefs, MODULE_REGEXP, (match) => {
         var moduleUrl = match[1];
         var alias = moduleAliases[moduleUrl];
         if (isBlank(alias)) {
           if (moduleUrl == this.moduleUrl) {
             alias = '';
           } else {
             alias = `import${imports.length}`;
             imports.push([moduleUrl, alias]);
           }
           moduleAliases[moduleUrl] = alias;
         }
         return alias.length > 0 ? `${alias}.` : '';
       });
   return new SourceWithImports(newSource, imports);
 }
开发者ID:Caplu,项目名称:ng2-dribbble,代码行数:20,代码来源:source_module.ts


注:本文中的angular2/src/facade/lang.StringWrapper.replaceAllMapped方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。