當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Bootloader.parseDocument方法代碼示例

本文整理匯總了TypeScript中angular2-universal.Bootloader.parseDocument方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Bootloader.parseDocument方法的具體用法?TypeScript Bootloader.parseDocument怎麽用?TypeScript Bootloader.parseDocument使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在angular2-universal.Bootloader的用法示例。


在下文中一共展示了Bootloader.parseDocument方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

AppShellPlugin.prototype.build = function () {
  var sourceHtml = fse.readFileSync(path.resolve(this.inputPaths[0], this.indexPath), 'utf-8');
  var options = {
    document: Bootloader.parseDocument(sourceHtml),
    directives: [ IssueCliApp ],
    providers: [
      provide(APP_BASE_HREF, {useValue: '/'}),
      provide(REQUEST_URL, {useValue: '/'}),
      provide(IS_POST_LOGIN, {
        useValue: false
      }),
      ROUTER_PROVIDERS,
      NODE_LOCATION_PROVIDERS,
      provide(IS_PRERENDER, {
        useValue: true
      }),
      FIREBASE_PROVIDERS,
      NODE_HTTP_PROVIDERS,
      provide(LOCAL_STORAGE, {
        useValue: {
          getItem: () => null,
          setItem: () => null
        }
      }),
      defaultFirebase('https://issue-zero.firebaseio.com')
    ],
    preboot: false
  }

    var bootloader = Bootloader.create(options);
    return bootloader.serializeApplication().then(html =>  fse.outputFileSync(path.resolve(this.outputPath, this.indexPath), html, 'utf-8'));
}
開發者ID:QuinntyneBrown,項目名稱:issue-zero,代碼行數:32,代碼來源:broccoli-app-shell.ts

示例2: generateHtml

export function generateHtml(opts: Options): Promise<string> {
    opts = Object.assign({
        originUrl: "http://localhost:8080",
        baseUrl: "/",
        reqUrl: "/",
        preboot: false,
    }, opts);

    let config: CliBootloaderConfig = {
        directives: [opts.component],
        platformProviders: [
            provide(ORIGIN_URL, { useValue: opts.originUrl }),
            provide(BASE_URL, { useValue: opts.baseUrl }),
        ],
        providers: [
            provide(REQUEST_URL, { useValue: opts.reqUrl }),
            ...NODE_ROUTER_PROVIDERS,
            ...NODE_HTTP_PROVIDERS,
        ],
        beautify: true,
        async: true,
    };

    enableProdMode();
    let doc = Bootloader.parseDocument(opts.templateHtml);
    config.document = doc;
    config.template = opts.templateHtml;
    config.preboot = opts.preboot;

    let bootloader = new Bootloader(config);
    return bootloader.serializeApplication();
}
開發者ID:gdi2290,項目名稱:ng-ssr-cli,代碼行數:32,代碼來源:index.ts

示例3: build

 build() {
   var sourceHtml = fs.readFileSync(path.resolve(this.inputPaths[0], this.indexPath), 'utf-8');
   var appShellOptions = require(path.resolve(this.inputPaths[0], this.appShellPath)).options;
   var options = Object.assign(appShellOptions, {
     document: Bootloader.parseDocument(sourceHtml),
   });
   var bootloader = Bootloader.create(options);
   return bootloader.serializeApplication()
     .then(html =>  fs.writeFileSync(path.resolve(this.outputPath, this.indexPath), html, 'utf-8'));
 }
開發者ID:axwl,項目名稱:universal,代碼行數:10,代碼來源:prerender.ts

示例4: build

 build() {
   var sourceHtml = fs.readFileSync(path.resolve(this.inputPaths[0], this.indexPath), 'utf-8');
   var appShellOptions = require(path.resolve(this.inputPaths[0], this.appShellPath)).options;
   var options = Object.assign(appShellOptions, {
     document: Bootloader.parseDocument(sourceHtml),
   });
   var bootloader = Bootloader.create(options);
   // Make sure to get all providers and platformProviders
   var providers = [].concat(options.providers || []).concat(options.platformProviders || []);
   return bootloader.serializeApplication(null, providers)
     .then(html =>  fs.writeFileSync(path.resolve(this.outputPath, this.indexPath), html, 'utf-8'));
 }
開發者ID:laskoviymishka,項目名稱:universal,代碼行數:12,代碼來源:prerender.ts

示例5: require

import 'angular2-universal-polyfills';
import {Bootloader} from 'angular2-universal';
import { disposePlatform } from '@angular/core';
const fs = require('fs');
const path = require('path');
const args = require('optimist').argv;
const appShellOptions = require(args.optionsPath).options;
const sourceHtml = fs.readFileSync(args.sourceHtml, 'utf-8');

var options = Object.assign(appShellOptions, {
  document: Bootloader.parseDocument(sourceHtml),
});
var bootloader = Bootloader.create(options);
// Make sure to get all providers and platformProviders
var providers = [].concat(options.providers || []).concat(options.platformProviders || []);
bootloader.serializeApplication(null, providers)
  .then(html =>  fs.writeFileSync(args.outputIndexPath, html, 'utf-8'))
  .then(() => process.exit(0))
  .catch(e => {
    if (e) console.error(e);
    process.exit(1);
  });
開發者ID:An0564,項目名稱:universal,代碼行數:22,代碼來源:child_proc.ts


注:本文中的angular2-universal.Bootloader.parseDocument方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。