marko 4.28.4 → 4.28.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/compiler/index.js
CHANGED
|
@@ -58,33 +58,35 @@ function isXML(path) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
function _compile(src, filename, userOptions, callback) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
ok(filename, '"filename" argument is required');
|
|
64
|
-
ok(typeof filename === "string", '"filename" argument should be a string');
|
|
65
|
-
|
|
66
|
-
var options = {};
|
|
61
|
+
try {
|
|
62
|
+
registerCoreTaglibs();
|
|
67
63
|
|
|
68
|
-
|
|
64
|
+
ok(filename, '"filename" argument is required');
|
|
65
|
+
ok(typeof filename === "string", '"filename" argument should be a string');
|
|
69
66
|
|
|
70
|
-
|
|
71
|
-
extend(options, userOptions);
|
|
72
|
-
}
|
|
67
|
+
var options = {};
|
|
73
68
|
|
|
74
|
-
|
|
69
|
+
extend(options, globalConfig);
|
|
75
70
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
71
|
+
if (userOptions) {
|
|
72
|
+
extend(options, userOptions);
|
|
73
|
+
}
|
|
80
74
|
|
|
81
|
-
|
|
75
|
+
var compiler = defaultCompiler;
|
|
82
76
|
|
|
83
|
-
|
|
77
|
+
if (isXML(filename)) {
|
|
78
|
+
require("complain")("Using Marko to build XML is deprecated");
|
|
79
|
+
options.ignoreUnrecognizedTags = true;
|
|
80
|
+
}
|
|
84
81
|
|
|
85
|
-
|
|
82
|
+
const context = new CompileContext(src, filename, compiler.builder, options);
|
|
86
83
|
const compiled = compiler.compile(src, context);
|
|
87
|
-
result = userOptions.sourceOnly ? compiled.code : compiled;
|
|
84
|
+
const result = userOptions.sourceOnly ? compiled.code : compiled;
|
|
85
|
+
if (callback) {
|
|
86
|
+
callback(null, result);
|
|
87
|
+
} else {
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
88
90
|
} catch (e) {
|
|
89
91
|
if (callback) {
|
|
90
92
|
return callback(e);
|
|
@@ -92,12 +94,6 @@ function _compile(src, filename, userOptions, callback) {
|
|
|
92
94
|
throw e;
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
|
-
|
|
96
|
-
if (callback) {
|
|
97
|
-
callback(null, result);
|
|
98
|
-
} else {
|
|
99
|
-
return result;
|
|
100
|
-
}
|
|
101
97
|
}
|
|
102
98
|
|
|
103
99
|
function compile(src, filename, options, callback) {
|
|
@@ -94,22 +94,22 @@ function getCachedTemplate(path) {
|
|
|
94
94
|
function getPreviousTemplate(templatePath, options) {
|
|
95
95
|
/*
|
|
96
96
|
The require.cache is search in the following order:
|
|
97
|
-
1) /path/to/my-template.js
|
|
98
|
-
2) /path/to/my-template.
|
|
97
|
+
1) /path/to/my-template.marko.js
|
|
98
|
+
2) /path/to/my-template.js
|
|
99
99
|
3) /path/to/my-template.marko
|
|
100
100
|
*
|
|
101
101
|
If the template is not found in require.cache and `assumeUpToDate` is true
|
|
102
102
|
then we will check the disk for the precompiled templates in the following
|
|
103
103
|
order:
|
|
104
|
-
1) /path/to/my-template.js
|
|
105
|
-
2) /path/to/my-template.
|
|
104
|
+
1) /path/to/my-template.marko.js
|
|
105
|
+
2) /path/to/my-template.js
|
|
106
106
|
*/
|
|
107
107
|
var ext = nodePath.extname(templatePath);
|
|
108
|
-
var
|
|
109
|
-
var
|
|
108
|
+
var targetPrecompiledMarkoJS = templatePath + ".js";
|
|
109
|
+
var targetPrecompiledJS = templatePath.slice(0, 0 - ext.length) + ".js";
|
|
110
110
|
|
|
111
111
|
// Short-circuit loading if the template has already been cached in the Node.js require cache
|
|
112
|
-
var cachedTemplate = getCachedTemplate(
|
|
112
|
+
var cachedTemplate = getCachedTemplate(targetPrecompiledMarkoJS) || getCachedTemplate(targetPrecompiledJS) || getCachedTemplate(templatePath);
|
|
113
113
|
|
|
114
114
|
if (cachedTemplate) {
|
|
115
115
|
return cachedTemplate;
|
|
@@ -119,12 +119,11 @@ function getPreviousTemplate(templatePath, options) {
|
|
|
119
119
|
templatePath = nodePath.resolve(cwd, templatePath);
|
|
120
120
|
|
|
121
121
|
if (options.assumeUpToDate) {
|
|
122
|
-
if (fs.existsSync(
|
|
123
|
-
return require(
|
|
122
|
+
if (fs.existsSync(targetPrecompiledMarkoJS)) {
|
|
123
|
+
return require(targetPrecompiledMarkoJS);
|
|
124
124
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return require(targetFileDebug);
|
|
125
|
+
if (fs.existsSync(targetPrecompiledJS)) {
|
|
126
|
+
return require(targetPrecompiledJS);
|
|
128
127
|
}
|
|
129
128
|
}
|
|
130
129
|
|
package/package.json
CHANGED
package/src/compiler/index.js
CHANGED
|
@@ -58,33 +58,40 @@ function isXML(path) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
function _compile(src, filename, userOptions, callback) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
ok(filename, '"filename" argument is required');
|
|
64
|
-
ok(typeof filename === "string", '"filename" argument should be a string');
|
|
65
|
-
|
|
66
|
-
var options = {};
|
|
61
|
+
try {
|
|
62
|
+
registerCoreTaglibs();
|
|
67
63
|
|
|
68
|
-
|
|
64
|
+
ok(filename, '"filename" argument is required');
|
|
65
|
+
ok(typeof filename === "string", '"filename" argument should be a string');
|
|
69
66
|
|
|
70
|
-
|
|
71
|
-
extend(options, userOptions);
|
|
72
|
-
}
|
|
67
|
+
var options = {};
|
|
73
68
|
|
|
74
|
-
|
|
69
|
+
extend(options, globalConfig);
|
|
75
70
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
71
|
+
if (userOptions) {
|
|
72
|
+
extend(options, userOptions);
|
|
73
|
+
}
|
|
80
74
|
|
|
81
|
-
|
|
75
|
+
var compiler = defaultCompiler;
|
|
82
76
|
|
|
83
|
-
|
|
77
|
+
if (isXML(filename)) {
|
|
78
|
+
require("complain")("Using Marko to build XML is deprecated");
|
|
79
|
+
options.ignoreUnrecognizedTags = true;
|
|
80
|
+
}
|
|
84
81
|
|
|
85
|
-
|
|
82
|
+
const context = new CompileContext(
|
|
83
|
+
src,
|
|
84
|
+
filename,
|
|
85
|
+
compiler.builder,
|
|
86
|
+
options
|
|
87
|
+
);
|
|
86
88
|
const compiled = compiler.compile(src, context);
|
|
87
|
-
result = userOptions.sourceOnly ? compiled.code : compiled;
|
|
89
|
+
const result = userOptions.sourceOnly ? compiled.code : compiled;
|
|
90
|
+
if (callback) {
|
|
91
|
+
callback(null, result);
|
|
92
|
+
} else {
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
88
95
|
} catch (e) {
|
|
89
96
|
if (callback) {
|
|
90
97
|
return callback(e);
|
|
@@ -92,12 +99,6 @@ function _compile(src, filename, userOptions, callback) {
|
|
|
92
99
|
throw e;
|
|
93
100
|
}
|
|
94
101
|
}
|
|
95
|
-
|
|
96
|
-
if (callback) {
|
|
97
|
-
callback(null, result);
|
|
98
|
-
} else {
|
|
99
|
-
return result;
|
|
100
|
-
}
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
function compile(src, filename, options, callback) {
|
|
@@ -96,24 +96,24 @@ function getCachedTemplate(path) {
|
|
|
96
96
|
function getPreviousTemplate(templatePath, options) {
|
|
97
97
|
/*
|
|
98
98
|
The require.cache is search in the following order:
|
|
99
|
-
1) /path/to/my-template.js
|
|
100
|
-
2) /path/to/my-template.
|
|
99
|
+
1) /path/to/my-template.marko.js
|
|
100
|
+
2) /path/to/my-template.js
|
|
101
101
|
3) /path/to/my-template.marko
|
|
102
102
|
*
|
|
103
103
|
If the template is not found in require.cache and `assumeUpToDate` is true
|
|
104
104
|
then we will check the disk for the precompiled templates in the following
|
|
105
105
|
order:
|
|
106
|
-
1) /path/to/my-template.js
|
|
107
|
-
2) /path/to/my-template.
|
|
106
|
+
1) /path/to/my-template.marko.js
|
|
107
|
+
2) /path/to/my-template.js
|
|
108
108
|
*/
|
|
109
109
|
var ext = nodePath.extname(templatePath);
|
|
110
|
-
var
|
|
111
|
-
var
|
|
110
|
+
var targetPrecompiledMarkoJS = templatePath + ".js";
|
|
111
|
+
var targetPrecompiledJS = templatePath.slice(0, 0 - ext.length) + ".js";
|
|
112
112
|
|
|
113
113
|
// Short-circuit loading if the template has already been cached in the Node.js require cache
|
|
114
114
|
var cachedTemplate =
|
|
115
|
-
getCachedTemplate(
|
|
116
|
-
getCachedTemplate(
|
|
115
|
+
getCachedTemplate(targetPrecompiledMarkoJS) ||
|
|
116
|
+
getCachedTemplate(targetPrecompiledJS) ||
|
|
117
117
|
getCachedTemplate(templatePath);
|
|
118
118
|
|
|
119
119
|
if (cachedTemplate) {
|
|
@@ -124,12 +124,11 @@ function getPreviousTemplate(templatePath, options) {
|
|
|
124
124
|
templatePath = nodePath.resolve(cwd, templatePath);
|
|
125
125
|
|
|
126
126
|
if (options.assumeUpToDate) {
|
|
127
|
-
if (fs.existsSync(
|
|
128
|
-
return require(
|
|
127
|
+
if (fs.existsSync(targetPrecompiledMarkoJS)) {
|
|
128
|
+
return require(targetPrecompiledMarkoJS);
|
|
129
129
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return require(targetFileDebug);
|
|
130
|
+
if (fs.existsSync(targetPrecompiledJS)) {
|
|
131
|
+
return require(targetPrecompiledJS);
|
|
133
132
|
}
|
|
134
133
|
}
|
|
135
134
|
|