Permalink
Browse files

Allow for other module extensions (other than .xml)

  • Loading branch information...
1 parent bb5f7f6 commit 9bebb602137fa2fc65c0335c206b37015cea9fe6 @adamstallard adamstallard committed Aug 31, 2013
Showing with 13 additions and 8 deletions.
  1. +12 −7 lib/modest-preview.js
  2. +1 −1 package.json
View
19 lib/modest-preview.js
@@ -15,7 +15,7 @@ this.modest = this.modest || {
loadModules : function(){
var modest = this.modest;
var includes = this.document.getElementsByTagName('include');
- var path, pathAttr, moduleName, moduleContent, i;
+ var path, pathAttr, moduleName, moduleContent, i, extension, lastDot;
for (i = 0; i < includes.length; ++i) {
@@ -27,6 +27,16 @@ this.modest = this.modest || {
moduleName = moduleName.replace(/^\s+/, '').replace(/\s+$/, '');
+ // Find and separate the extension. If no extension is given, assume '.xml'
+
+ lastDot = moduleName.lastIndexOf('.');
+ if(lastDot == -1){
+ extension = '.xml';
+ } else {
+ extension = moduleName.substring(lastDot);
+ moduleName = moduleName.substring(0, lastDot);
+ }
+
if (!modest.compiled[moduleName]) {
path = '';
pathAttr = includes[i].getAttribute('path');
@@ -36,12 +46,7 @@ this.modest = this.modest || {
path = pathAttr.replace(/[\/\\\s]+$/, '') + '/';
}
-
- path += moduleName;
-
- // Append ".xml" if the path doesn't already end with it
-
- path = path.replace(/\.xml$/, '') + '.xml';
+ path += moduleName + extension;
moduleContent = modest.localFile(path);
modest.$uncompiled[moduleName] = $(moduleContent);
}
View
2 package.json
@@ -1,6 +1,6 @@
{
"name" : "modest",
- "version" : "1.21.1",
+ "version" : "1.22.0",
"description" : "Create HTML modules (building blocks) that look like new HTML tags. Use modules to form other modules. Easily pass parameters from multiple sources to modules and inner modules. Use as a drop-in templating language to any web framework.",
"keywords" : ["xhtml","html","semantic","template","templating","preview","modular","tags","modules","browser","web"],
"author" : {

0 comments on commit 9bebb60

Please sign in to comment.