Fixes #262 - node-require module removes .marko extension from filenames in compiled code

This commit is contained in:
Patrick Steele-Idem 2016-04-18 11:32:33 -06:00
parent 6a27121961
commit 640a5a05ce
5 changed files with 30 additions and 1 deletions

View File

@ -14,6 +14,12 @@ var macros = require('./util/macros');
var extend = require('raptor-util/extend');
var Walker = require('./Walker');
const deresolveOptions = {
shouldRemoveExt(ext) {
return ext === '.js' || ext === '.json' || ext === '.es6';
}
};
function getTaglibPath(taglibPath) {
if (typeof window === 'undefined') {
return path.relative(process.cwd(), taglibPath);
@ -115,7 +121,7 @@ class CompileContext {
}
getRequirePath(targetFilename) {
return deresolve(targetFilename, this.dirname);
return deresolve(targetFilename, this.dirname, deresolveOptions);
}
importModule(varName, path) {

View File

@ -0,0 +1,16 @@
function create(__helpers) {
var str = __helpers.s,
empty = __helpers.e,
notEmpty = __helpers.ne,
escapeXml = __helpers.x,
loadTemplate = __helpers.l,
__hello = loadTemplate(require.resolve("./hello.marko"));
return function render(data, out) {
__hello.render({
name: "Frank"
}, out);
};
}
(module.exports = require("marko").c(__filename)).c(create);

View File

@ -0,0 +1 @@
- Hello ${data.name}!

View File

@ -0,0 +1,5 @@
{
"<hello>": {
"template": "./hello.marko"
}
}

View File

@ -0,0 +1 @@
<hello name="Frank"/>