本文整理汇总了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);
示例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';
示例3: initNodeAdapter
export function initNodeAdapter() {
Parse5DomAdapter.makeCurrent();
}