mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Allow non-Marko templates to also be loaded through the view-engine
This commit is contained in:
parent
9ac277bf75
commit
2f7cac5ef9
@ -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: */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user