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


TypeScript Server.views方法代碼示例

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


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

示例1: require

server.register(Vision, {}, (err) => {
    server.views({
        engines: {
            html: require('handlebars')
        }
  });
});
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:7,代碼來源:error-representation.ts

示例2: require

server.register(Vision, (err) => {

    if (err) {
        throw err;
    }

    server.views({
        engines: { html: require('handlebars') },
        path: __dirname + '/templates'
    });

    var opts: Hapi.CompileOptions = {
        noEscape: true
    };

    server.route({
        method: 'GET',
        path: '/temp1',
        handler: {
            view: {
                template: 'temp1',
                options: {
                    compileOptions: opts
                }
            }
        }
    });
});
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:28,代碼來源:vision-tests.ts

示例3: hapiEngine

  app.register([Vision, Inert], (err) => {

    if (err) {
      throw err;
    }

    // rendering engine
    app.views({
      defaultExtension: 'ng2.html',
      engines: {
        'ng2.html': {
          module: new hapiEngine(),
          compileMode: 'async'
        }
      },
      relativeTo: __dirname,
      path: path.join(ROOT, 'examples')
    });

  });
開發者ID:BizagiStudio,項目名稱:universal,代碼行數:20,代碼來源:server.ts

示例4:

            rootElement: Provider,
            template: "./index",
            muiThemeOptions,
            renderToStaticMarkup: true,
            params: {
                bundleName
            }
        }
    }
];

server.register(plugins, (err) => {

    if (err) {
        console.error(err);
    }
});

server.views({
    engines: { hbs: Handlebars }
});

new Exiting.Manager(server).start((err) => {

    if (err) {
        throw err;
    }

    console.log("Production server started at", server.info.uri);
});
開發者ID:vandemataramlib,項目名稱:vml-web,代碼行數:30,代碼來源:prodServer.ts

示例5: async

const provision = async () => {
    await server.register({
        plugin: Vision,
        options: {
            engines: { hbs: Handlebars },
            path: __dirname + '/templates',
        }
    });

    server.views({
        engines: { hbs: Handlebars },
        path: __dirname + '/templates',
    });

    const context = {
        title: 'Views Example',
        message: 'Hello, World',
    };

    console.log(await server.render('hello', context));

    server.route({
        method: 'GET',
        path: '/view',
        handler: async (request: Request, h: ResponseToolkit) => {
            return request.render('test', { message: 'hello' });
        },
    });

    server.route({
        method: 'GET',
        path: '/',
        handler: {
            view: {
                template: 'hello',
                context: {
                    title: 'Views Example',
                    message: 'Hello, World',
                },
            },
        },
    });

    const handler = (request: Request, h: ResponseToolkit) => {
        const context = {
            title: 'Views Example',
            message: 'Hello, World',
        };
        return h.view('hello', context);
    };

    server.route({ method: 'GET', path: '/', handler });

    server.route({
        method: 'GET',
        path: '/temp1',
        handler: {
            view: {
                template: 'temp1',
                options: {
                    compileOptions: {
                        noEscape: true,
                    },
                },
            },
        },
    });
};
開發者ID:Dru89,項目名稱:DefinitelyTyped,代碼行數:68,代碼來源:vision-tests.ts

示例6: require

        options: {
            template: "index",
            context: {
                context: JSON.stringify({}),
                bundleName: "bundle.js"
            }
        }
    },
    StaticFileServer
];

server.register(plugins, (err) => {

    if (err) {
        throw err;
    }
});

server.views({
    engines: { hbs: require("handlebars") }
});

new Exiting.Manager(server).start(err => {

    if (err) {
        throw err;
    }

    console.log("Development server started at", server.info.uri);
});
開發者ID:vandemataramlib,項目名稱:vml-web,代碼行數:30,代碼來源:devServer.ts


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