当前位置: 首页>>代码示例>>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;未经允许,请勿转载。