Skip to content

Commit

Permalink
added functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
shimondoodkin committed Jun 26, 2010
1 parent 3012ef8 commit 1fc5a95
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
7 changes: 2 additions & 5 deletions README.md
Expand Up @@ -72,17 +72,14 @@ A template that processed twice:




### to include in in nodejs I use: ### 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 te = require('doubletemplate'); //load double teplate module
var doubletemplate=te.doubletemplate; // export double template function to global var doubletemplate=te.doubletemplate; // export double template function to global


### example of useing `parsedir` function: ### example of useing `parsedir` function:
te.parsedir(fs,__dirname+'/templates',{'app':app}); te.parsedir(__dirname+'/templates',{'app':app});


### example of useing `loadfile` function: ### 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: ### in the code you can use:
te.templates['subdir/filename.html']({'app':app}); te.templates['subdir/filename.html']({'app':app});
Expand Down
18 changes: 11 additions & 7 deletions doubletemplate.js
Expand Up @@ -58,16 +58,14 @@
//</html> //</html>
// //


var fs = require('fs'); // lets open files


// to include in in nodejs i use: // 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 te = require('doubletemplate'); //load double teplate module
// var doubletemplate=te.doubletemplate; // export double template function to global // var doubletemplate=te.doubletemplate; // export double template function to global


//example of useing parsedir function: //example of useing parsedir function:
// te.parsedir(fs,__dirname+'/templates',{'app':app}); // te.parsedir(__dirname+'/templates',{'app':app});


//in the code you use: //in the code you use:
// te.templates['subdir/filename.html']({'app':app}); // te.templates['subdir/filename.html']({'app':app});
Expand Down Expand Up @@ -295,7 +293,7 @@ function doubletemplate(template,statictata)
//run recusivly on a directory to load all templates in it. //run recusivly on a directory to load all templates in it.


var templates={}; this.templates=templates; var templates={}; this.templates=templates;
function parsedir(fs,parsedirname,dataobject) function parsedir(parsedirname,dataobject)
{ {
//example: //example:
// te.parsedir(__dirname+'/templates',{'app':app}); // te.parsedir(__dirname+'/templates',{'app':app});
Expand Down Expand Up @@ -341,7 +339,7 @@ function parsedir(fs,parsedirname,dataobject)
}this.parsedir=parsedir; }this.parsedir=parsedir;


///////// /////////
function loadfile(fs,file,dataobject,basedir) function loadfile(file,dataobject,basedir)
{ {
if(basedir==null) basedir=dir; if(basedir==null) basedir=dir;
//example: //example:
Expand All @@ -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;

0 comments on commit 1fc5a95

Please sign in to comment.