mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Fixes #262 - node-require module removes .marko extension from filenames in compiled code
This commit is contained in:
parent
6a27121961
commit
640a5a05ce
@ -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) {
|
||||
|
||||
16
test/fixtures/compiler/autotest/custom-tag-template/expected.js
vendored
Normal file
16
test/fixtures/compiler/autotest/custom-tag-template/expected.js
vendored
Normal 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);
|
||||
1
test/fixtures/compiler/autotest/custom-tag-template/hello.marko
vendored
Normal file
1
test/fixtures/compiler/autotest/custom-tag-template/hello.marko
vendored
Normal file
@ -0,0 +1 @@
|
||||
- Hello ${data.name}!
|
||||
5
test/fixtures/compiler/autotest/custom-tag-template/marko.json
vendored
Normal file
5
test/fixtures/compiler/autotest/custom-tag-template/marko.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"<hello>": {
|
||||
"template": "./hello.marko"
|
||||
}
|
||||
}
|
||||
1
test/fixtures/compiler/autotest/custom-tag-template/template.marko
vendored
Normal file
1
test/fixtures/compiler/autotest/custom-tag-template/template.marko
vendored
Normal file
@ -0,0 +1 @@
|
||||
<hello name="Frank"/>
|
||||
Loading…
x
Reference in New Issue
Block a user