Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added functionality

  • Loading branch information...
commit 1fc5a9507e106202bc00a073e03df4bef5e925ea 1 parent 3012ef8
Shimon Doodkin authored
Showing with 13 additions and 12 deletions.
  1. +2 −5 README.md
  2. +11 −7 doubletemplate.js
7 README.md
View
@@ -72,17 +72,14 @@ A template that processed twice:
### to include in in nodejs I use:
- // require.paths.unshift(__dirname); //make local paths accecible
- // require('filename') // include file - filename is without '.js' extention!!!
- // var fs = require('fs'); // lets open files
var te = require('doubletemplate'); //load double teplate module
var doubletemplate=te.doubletemplate; // export double template function to global
### example of useing `parsedir` function:
- te.parsedir(fs,__dirname+'/templates',{'app':app});
+ te.parsedir(__dirname+'/templates',{'app':app});
### example of useing `loadfile` function:
- te.loadfile(fs,__dirname+'/templates/filename.html',{'app':app},__dirname);
+ te.loadfile(__dirname+'/templates/filename.html',{'app':app},__dirname);
### in the code you can use:
te.templates['subdir/filename.html']({'app':app});
18 doubletemplate.js
View
@@ -58,16 +58,14 @@
//</html>
//
+var fs = require('fs'); // lets open files
// to include in in nodejs i use:
-// // require.paths.unshift(__dirname); //make local paths accecible
-// // require('filename') // include file - filename is without '.js' extention!!!
-// // var fs = require('fs'); // lets open files
// var te = require('doubletemplate'); //load double teplate module
// var doubletemplate=te.doubletemplate; // export double template function to global
//example of useing parsedir function:
-// te.parsedir(fs,__dirname+'/templates',{'app':app});
+// te.parsedir(__dirname+'/templates',{'app':app});
//in the code you use:
// te.templates['subdir/filename.html']({'app':app});
@@ -295,7 +293,7 @@ function doubletemplate(template,statictata)
//run recusivly on a directory to load all templates in it.
var templates={}; this.templates=templates;
-function parsedir(fs,parsedirname,dataobject)
+function parsedir(parsedirname,dataobject)
{
//example:
// te.parsedir(__dirname+'/templates',{'app':app});
@@ -341,7 +339,7 @@ function parsedir(fs,parsedirname,dataobject)
}this.parsedir=parsedir;
/////////
-function loadfile(fs,file,dataobject,basedir)
+function loadfile(file,dataobject,basedir)
{
if(basedir==null) basedir=dir;
//example:
@@ -364,4 +362,10 @@ function loadfile(fs,file,dataobject,basedir)
}
}
});
-}this.loadfile=loadfile;
+}this.loadfile=loadfile;
+
+/////////
+function loadtemplate(file,dataobject)
+{
+ return doubletemplate(fs.readFileSync(file_on_callback),dataobject);
+}this.loadtemplate=loadtemplate;
Please sign in to comment.
Something went wrong with that request. Please try again.