mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Merge pull request #20 from bkniffler/master
Add support for .marko.html templates
This commit is contained in:
commit
44f14308b8
@ -242,7 +242,7 @@ if (args.clean) {
|
||||
file: function(file, context) {
|
||||
var basename = nodePath.basename(file);
|
||||
|
||||
if (basename.endsWith('.marko.js') || basename.endsWith('.marko.xml.js')) {
|
||||
if (basename.endsWith('.marko.js') || basename.endsWith('.marko.html') || basename.endsWith('.marko.xml.js')) {
|
||||
context.beginAsync();
|
||||
fs.unlink(file, function(err) {
|
||||
if (err) {
|
||||
@ -314,7 +314,7 @@ if (args.clean) {
|
||||
file: function(file, context) {
|
||||
var basename = nodePath.basename(file);
|
||||
|
||||
if (basename.endsWith('.marko') || basename.endsWith('.marko.xml')) {
|
||||
if (basename.endsWith('.marko') || basename.endsWith('.marko.html') || basename.endsWith('.marko.xml')) {
|
||||
compile(file, context);
|
||||
}
|
||||
}
|
||||
|
||||
@ -280,6 +280,8 @@ function scanTagsDir(tagsConfigPath, tagsConfigDirname, dir, taglib) {
|
||||
tagDef.renderer = rendererFile;
|
||||
} else if (fs.existsSync(templateFile)) {
|
||||
tagDef.template = templateFile;
|
||||
} else if (fs.existsSync(templateFile + ".html")) {
|
||||
tagDef.template = templateFile + ".html";
|
||||
} else {
|
||||
throw new Error('Invalid tag file: ' + tagFile + '. Neither a renderer or a template was found for tag.');
|
||||
}
|
||||
@ -303,14 +305,23 @@ function scanTagsDir(tagsConfigPath, tagsConfigDirname, dir, taglib) {
|
||||
tag = buildTag(tagDef, tagsConfigPath, taglib, tagDirname);
|
||||
tag.name = childFilename;
|
||||
taglib.addTag(tag);
|
||||
} else if (fs.existsSync(templateFile)) {
|
||||
var templateCode = fs.readFileSync(templateFile, {encoding: 'utf8'});
|
||||
tagDef = tagDefFromCode.extractTagDef(templateCode);
|
||||
if (!tagDef) {
|
||||
tagDef = createDefaultTagDef();
|
||||
} else {
|
||||
var exTemplateFile;
|
||||
if (fs.existsSync(templateFile)) {
|
||||
exTemplateFile = templateFile;
|
||||
}
|
||||
else if (fs.existsSync(templateFile + ".html")){
|
||||
exTemplateFile = templateFile + ".html";
|
||||
}
|
||||
if(exTemplateFile){
|
||||
var templateCode = fs.readFileSync(exTemplateFile, {encoding: 'utf8'});
|
||||
tagDef = tagDefFromCode.extractTagDef(templateCode);
|
||||
if (!tagDef) {
|
||||
tagDef = createDefaultTagDef();
|
||||
}
|
||||
|
||||
tagDef.template = templateFile;
|
||||
tagDef.template = exTemplateFile;
|
||||
}
|
||||
}
|
||||
|
||||
if (tagDef) {
|
||||
|
||||
@ -60,13 +60,14 @@ exports.handleFileModified = function(path) {
|
||||
var basename = nodePath.basename(path);
|
||||
|
||||
if (path.endsWith('.marko') ||
|
||||
path.endsWith('.marko.html') ||
|
||||
path.endsWith('.marko.xml') ||
|
||||
basename === 'marko-tag.json' ||
|
||||
basename === 'marko-taglib.json') {
|
||||
|
||||
console.log('[marko/hot-reload] File modified: ' + path);
|
||||
|
||||
if (path.endsWith('.marko')) {
|
||||
if (path.endsWith('.marko') || path.endsWith('.marko.html')) {
|
||||
delete require.cache[path + '.js'];
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +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)?$/;
|
||||
var markoRegExp = /\.marko(.xml|.html)?$/;
|
||||
var req = require;
|
||||
|
||||
function notEmpty(o) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user