Allow non-Marko templates to also be loaded through the view-engine

This commit is contained in:
Patrick Steele-Idem 2014-10-15 09:46:45 -06:00
parent 9ac277bf75
commit 2f7cac5ef9

View File

@ -5,6 +5,7 @@ var extend = require('raptor-util/extend');
var attr = require('raptor-util/attr');
var attrs = require('raptor-util/attrs');
var forEach = require('raptor-util/forEach');
var markoRegExp = /\.marko(.xml)?$/;
function notEmpty(o) {
if (Array.isArray(o) === true) {
@ -82,7 +83,16 @@ module.exports = {
as: attrs,
l: function(path) {
return typeof path === 'string' ? runtime.load(path) : path;
if (typeof path === 'string') {
if (markoRegExp.test(path)) {
return runtime.load(path);
} else {
return require('view-engine').load(path);
}
} else {
// Assume it is already a pre-loaded template
return path;
}
},
/* Helpers that require a context below: */