本文整理汇总了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/')));
}
示例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.");
}
示例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);
};
}
示例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);
示例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`
}),
}));