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


TypeScript express-handlebars.create函数代码示例

本文整理汇总了TypeScript中express-handlebars.create函数的典型用法代码示例。如果您正苦于以下问题:TypeScript create函数的具体用法?TypeScript create怎么用?TypeScript create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: constructor

    constructor() { 
        /**
         * instantiate App
         */
        this._app = express();
        this._app.enable('trust proxy');
        const hbs = handlebars.create({ defaultLayout: "main" });        

        /**
         * configure bodyParser and handlebars
         */
        this._app.use(bodyParser.json());
        this._app.use("/", router);
        this._app.use(bodyParser.json());
        this._app.use(bodyParser.urlencoded({extended: false}));
        this._app.set("port", (process.env.PORT || 8080));
        this._app.engine("handlebars", hbs.engine);
        this._app.set("view engine", "handlebars");
    }    
开发者ID:sth144,项目名称:people-api-oauth,代码行数:19,代码来源:app.ts

示例2: function

export default function(app) {
    var hbs = exphbs.create({
        defaultLayout: 'layout',
        helpers: {
            json: function(object) {
                return object ? JSON.stringify(object) : "null";
            },
            section: function(name, options) {
                if (!this._sections) {
                    this._sections = {};
                }
                this._sections[name] = options.fn(this);
                return null;
            },
            console: function(object) {
                console.log(object);
            },
            typeof: function(object) {
                return typeof object;
            },
            keys: function(object) {
                return Object.keys(object);
            },
            iftext: function(object, ifTrue, ifFalse) {
                if (object) {
                    return ifTrue;
                } else {
                    return ifFalse;
                }
            }
        }
    });
    app.engine(hbs.extname, hbs.engine);
    app.set('view engine', hbs.extname);
    return hbs;
};
开发者ID:sjohnsonaz,项目名称:build-launchpad,代码行数:36,代码来源:handlebars.ts

示例3: createHandlebars

 private createHandlebars (): Exphbs {
   return exphbs.create({
     defaultLayout: "main",
     helpers: templateHelpers,
   });
 }
开发者ID:drublic,项目名称:vc,代码行数:6,代码来源:WebServer.ts

示例4: Config

import { HomeController } from './controllers/home.controller';
import { Router } from './router';
import { Config } from './config';
var config = new Config();

var homeController = new HomeController();

var app = express();
app.use(express.static('public'));
// use router
app.use('/', new Router().router);
// use cookie and session
app.use(cookieParser(config.session_secret));
app.use(session({
  secret: config.session_secret,
  resave: false,
  saveUninitialized: true,
  cookie: { secure: false }
}));
//register view engine
app.engine('html', handlebars.create({ defaultLayout: "main", extname: '.html' }).engine);
app.set('view engine', 'html');

// bodyParser
app.use(bodyParser.json({ limit: '1mb' }));
app.use(bodyParser.urlencoded({ extended: true, limit: '1mb' }));

app.get('/', homeController.index);
app.listen(config.port, function () {
  console.log(`Example app listening on port ${config.port}!`);
});
开发者ID:AndrewZheng,项目名称:tsnodeprofiles,代码行数:31,代码来源:index.ts

示例5: express

import * as express from 'express';
import * as path from 'path';
import * as ExpressHandlebars from 'express-handlebars';
import * as bodyParser from 'body-parser';
import * as multer from 'multer';

import './db';
import './models';
import { productController } from './controllers/product';
import { searchController } from './controllers/search';

const app = express();

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true}));

app.get('/', function(req, res) {
    res.send("hello world");
});

productController.registerRoutes(app);
searchController.registerRoutes(app);

// set handlebars as view engine
const handlebars = ExpressHandlebars.create({ defaultLayout: 'main' });
app.engine('handlebars', handlebars.engine);
app.set('view engine', 'handlebars');

const server = app.listen(8080);

开发者ID:jacobleesinger,项目名称:inventory_microsite,代码行数:29,代码来源:index.ts

示例6: require

import * as core from "express-serve-static-core";
import path = require("path");
import bodyParser = require("body-parser"); 
import fs = require("fs");
var exphbs = require('express-handlebars');
import favicon = require("serve-favicon");
import logger = require("morgan");
import cookieParser = require("cookie-parser");
import helmet = require("helmet");
import compression = require("compression");

var routes = require('./routes/index');
var users = require('./routes/users');

var app: core.Express = express();
var hbs = exphbs.create();

importTemplates(projetRacine + "views/template", hbs.handlebars);

if (app.get('env') !== 'development') {
  app.use(helmet())
  app.use(compression());
  app.enable('view cache');
}else{
  app.use(logger('dev'));
}

// view engine setup
app.set('views', path.join(projetRacine, 'views'));
app.engine('handlebars', hbs.engine);
app.set('view engine', 'handlebars');
开发者ID:lucasBertola,项目名称:Turnkey,代码行数:31,代码来源:app.ts

示例7: express

// let appInsights = require("applicationinsights");
// let instrumentationKey = config.get("app.instrumentationKey");
// if (instrumentationKey) {
//     appInsights.setup(instrumentationKey).start();
// }

let app = express();

app.set("port", process.env.PORT || 3978);
app.use(express.static(path.join(__dirname, "../../public")));
app.use(express.static(path.join(__dirname, "./public"))); // used for static dialogs
app.use(favicon(path.join(__dirname, "../../public/assets", "favicon.ico")));

let handlebars = exphbs.create({
    extname: ".hbs",
    helpers: {
        appId: () => { return config.get("app.appId"); },
    },
});
app.engine("hbs", handlebars.engine);
app.set("view engine", "hbs");

// Tab and Popup urls
app.get("/loading", LoadingTab.getRequestHandler());
app.get("/default", DefaultTab.getRequestHandler());
app.get("/allCommands", AllCommandsTab.getRequestHandler());
app.get("/vstsAuth", VSTSAuthTab.getRequestHandler());
app.get("/vstsAuthFlowStart", VSTSAuthFlowStartPopUp.getRequestHandler());
app.get("/vstsAuthFlowEnd", VSTSAuthFlowEndPopUp.getRequestHandler());
app.get("/composeExtensionSettings", ComposeExtensionSettingsPopUp.getRequestHandler());

// Tab authentication sample routes
开发者ID:gvprime,项目名称:microsoft-teams-sample-complete-node,代码行数:32,代码来源:app.ts

示例8: express

import * as providers from "./providers";
import * as storage from "./storage";
import { AuthBot } from "./AuthBot";
import { logger } from "./utils/index";

let app = express();
let appId = config.get("app.appId");

app.set("port", process.env.PORT || 3978);
app.use(express.static(path.join(__dirname, "../../public")));
app.use(favicon(path.join(__dirname, "../../public/assets", "favicon.ico")));
app.use(bodyParser.json());

let handlebars = exphbs.create({
    extname: ".hbs",
    helpers: {
        appId: () => { return appId; },
    },
});
app.engine("hbs", handlebars.engine);
app.set("view engine", "hbs");

// Configure storage
let botStorageProvider = config.get("storage");
let botStorage = null;
switch (botStorageProvider) {
    case "mongoDb":
        botStorage = new storage.MongoDbBotStorage(config.get("mongoDb.botStateCollection"), config.get("mongoDb.connectionString"));
        break;
    case "memory":
        botStorage = new storage.MemoryBotStorage();
        break;
开发者ID:billbliss,项目名称:microsoft-teams-sample-auth-node,代码行数:32,代码来源:app.ts

示例9: express

/// <reference path="../typings/index.d.ts" />
import * as express from "express";
import * as hbs from "express-handlebars";
import * as path from "path";


import Config from "../config/config";
import * as apiRoute from "./api/router";


var app = express();
app.engine('html', hbs.create({extname: '.html', layoutsDir: __dirname + '../src/'}).engine);
app.set('views',path.join(__dirname,'../src/'));
app.set('view engine', 'html');

app.use('/', function (req, res, next) {
  var hostname = req.headers['host'].split(":")[0].split('.');

  if (hostname.length <= 3) {
    if (Config.subDomains.indexOf(hostname[0]) > -1) {
      app.use('/', apiRoute);
    }
  }

  next();
});

app.use('/', function (req, res,next) {
  if(Config.pages.indexOf(req.url.substr(1)) > -1 ){
    res.render('index',{
      scripts:Config.scripts
开发者ID:WassimBenzarti,项目名称:website,代码行数:31,代码来源:server.ts


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