本文整理汇总了TypeScript中@angular/platform-server/src/parse5_adapter.Parse5DomAdapter类的典型用法代码示例。如果您正苦于以下问题:TypeScript Parse5DomAdapter类的具体用法?TypeScript Parse5DomAdapter怎么用?TypeScript Parse5DomAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Parse5DomAdapter类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: isTag
import {OpaqueToken} from '@angular/core';
import {Parser, Serializer, TreeAdapters} from 'parse5';
import {Parse5DomAdapter} from '@angular/platform-server/src/parse5_adapter';
Parse5DomAdapter.makeCurrent(); // ensure Parse5DomAdapter is used
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
var DOM: any = getDOM();
const parser = new Parser(TreeAdapters.htmlparser2);
// TODO(gdi2290): fix encodeHtmlEntities: true
const serializer = new Serializer(TreeAdapters.htmlparser2, { encodeHtmlEntities: false });
const treeAdapter = parser.treeAdapter;
export function isTag(tagName, node): boolean {
return node.type === 'tag' && node.name === tagName;
}
export function parseFragment(el: string): Object {
return parser.parseFragment(el);
}
export function parseDocument(documentHtml: string): Object {
if (!documentHtml) {
throw new Error('parseDocument requires a document string');
}
if (typeof documentHtml !== 'string') {
throw new Error('parseDocument needs to be a string to be parsed correctly');
}
const doc = parser.parse(documentHtml);
开发者ID:filipesilva,项目名称:universal,代码行数:30,代码来源:document.ts
示例2:
// dom closure
import {Parse5DomAdapter} from '@angular/platform-server/src/parse5_adapter';
Parse5DomAdapter.makeCurrent();
export {provide, Inject, Optional, enableProdMode} from '@angular/core';
export * from './directives/index';
export * from './http/index';
export * from './pipes/index';
export * from './platform/index';
export * from './router/index';
export * from './env';
export * from './bootloader';
export * from './helper';
export * from './ng_preboot';
export * from './render';
export * from './stringify_element';
export * from 'angular2-express-engine';
export * from 'angular2-hapi-engine';
开发者ID:filipesilva,项目名称:universal,代码行数:26,代码来源:node.ts
示例3: initNodeAdapter
export function initNodeAdapter() {
Parse5DomAdapter.makeCurrent();
}
开发者ID:filipesilva,项目名称:universal,代码行数:3,代码来源:node.ts
注:本文中的@angular/platform-server/src/parse5_adapter.Parse5DomAdapter类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论