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


TypeScript swig.setDefaults函數代碼示例

本文整理匯總了TypeScript中swig.setDefaults函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript setDefaults函數的具體用法?TypeScript setDefaults怎麽用?TypeScript setDefaults使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: templates

    public templates() {
        // Swig template engine configs
        this.app.engine('html', swig.renderFile);
        this.app.set('view engine', 'html');
        this.app.set('views', path.join(__dirname + '/../../views'));
        this.app.set('view cache', false);
        // To disable Swig's cache, do the following:
        swig.setDefaults({ cache: false });

        // Load static files
        this.app.use(express.static(path.join(__dirname, '/../../assets')));
        this.app.use(express.static(path.join(__dirname, '/../../src/client/')));
    }
開發者ID:Dastagirireddy,項目名稱:semi-singlepage-app,代碼行數:13,代碼來源:app.ts

示例2: setup

    public setup() {
        this.logger.debug("Configuring view engine....");

        this.app.engine("html", swig.renderFile);
        let viewPath = Path.dirname(module.parent.parent.filename) + Express.viewPath;

        this.logger.debug("Configuring view path: " + viewPath);

        this.app.set("view engine", "html");
        this.app.set("views", viewPath);

		let enableCaching = HostingEnvironment.isProduction();

        this.logger.debug("View Caching enabled: " + enableCaching);

        this.app.set("view cache", enableCaching);
        swig.setDefaults({ cache: enableCaching });

        this.logger.debug("View engine configured.");
    }
開發者ID:Event-Starter-Kit,項目名稱:website,代碼行數:20,代碼來源:008.viewEngine.ts

示例3: createRender

export function createRender(configs: Configs): RenderFunction {
    const debug = configs.ServerRunningOptions.debug;
    const prefix = configs.flaskOptions.templatesPath;

    if (debug) swig.setDefaults({ cache: false });

    swig.setFilter('static', function(input: string) {
        return './' + configs.flaskOptions.staticUrlPath + '/' + input;
    });

    return function render(templatePath: string, data?: Object): string {
        let template;
        if (/\.html$/.test(templatePath)) {
            let realPath = join(prefix, templatePath);
            template = swig.compileFile(realPath);
        } else {
            template = swig.compile(templatePath);
        }

        return template(data);
    };
}
開發者ID:lleobox,項目名稱:flask-node,代碼行數:22,代碼來源:render.ts

示例4: require



// init
app.use(morgan('dev'));

// view engine
var swig: { setDefaults: any, renderFile: any } = require('swig');

app.engine('html', swig.renderFile);
app.set('view engine', 'html');
app.set('views', path.join(wwwRoot, 'views'));
app.set('view cache', false);

swig.setDefaults({
    varControls: ['[{', '}]'],
    tagControls: ['[%', '%]'],
    cmtControls: ['[#', '#]'],
    cache: false
});


// public assets
app.use('/public', express.static(path.join(wwwRoot, 'public')));
app.use('/public/*', SysopRoute.web404);

app.use('/bower_components', express.static(path.join(wwwRoot, 'bower_components')));
app.use('/bower_components/*', SysopRoute.web404);

// router`s
app.use('/api', new ApiRoot().root);
app.use('/api/*', SysopRoute.api404);
開發者ID:Farcek,項目名稱:samplesolution,代碼行數:29,代碼來源:serve.ts

示例5: serve

app.use(favicon(`${__dirname}/../../assets/images/favicon.png`));

if (SERVER_ROBOTS_TXT) {
    app.use('/robots.txt', serve('assets/resources/robots.txt'));
} else {
    app.use('/robots.txt', serve('assets/resources/nobots.txt'));
}

if (CLIENT_DEBUG_INFO) {
    app.use('/app', index('app'));
    app.use('/assets', index('assets'));
}

if (!SERVER_VIEW_CACHING) {
    app.set('view cache', false);
    swig.setDefaults({ cache: false });
}

app.use(body_parser.json());
app.use(cookie(process.env.CP_COOKIE_KEY));

app.use(session({
    name: 'cp.session',
    secret: KEY_SESSION,
    saveUninitialized: false,
    resave: false,
    store: new LokiStore({
        path: `${__dirname}/../../build/session.db`
    }),
}));
開發者ID:consumr-project,項目名稱:cp,代碼行數:30,代碼來源:main.ts


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