Add a new cachify_prefetch helper

This generates <link rel="prefetch"> tags which provide prefetching
hints to browsers that support this HTML5 feature.
This commit is contained in:
Francois Marier 2012-11-28 14:47:38 +13:00
Родитель ada022e23c
Коммит 162423e97a
1 изменённых файлов: 9 добавлений и 0 удалений

Просмотреть файл

@ -51,12 +51,14 @@ exports.setup = function (assets, options) {
true_path, exists;
if (typeof resp.local === 'function') {
resp.local('cachify_prefetch', cachify_prefetch);
resp.local('cachify_js', cachify_js);
resp.local('cachify_css', cachify_css);
resp.local('cachify', cachify);
}
else if (typeof resp.locals === 'function') {
resp.locals({
cachify_prefetch: cachify_prefetch,
cachify_js: cachify_js,
cachify_css: cachify_css,
cachify: cachify
@ -187,6 +189,13 @@ var cachify_css = exports.cachify_css = function (filename, options) {
options.hash);
};
var cachify_prefetch = exports.cachify_prefetch = function (filename, options) {
if (! options) options = {};
return prod_or_dev_tags(filename,
'<link rel="prefetch" href="%s">',
options.hash);
};
var cachify = exports.cachify = function (filename, options) {
var tag_format;
if (! options) options = {};