Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added functionality

  • Loading branch information...
commit 1fc5a9507e106202bc00a073e03df4bef5e925ea 1 parent 3012ef8
Shimon Doodkin authored

Showing 2 changed files with 13 additions and 12 deletions. Show diff stats Hide diff stats

  1. +2 5 README.md
  2. +11 7 doubletemplate.js
7 README.md
Source Rendered
@@ -72,17 +72,14 @@ A template that processed twice:
72 72
73 73
74 74 ### to include in in nodejs I use:
75   - // require.paths.unshift(__dirname); //make local paths accecible
76   - // require('filename') // include file - filename is without '.js' extention!!!
77   - // var fs = require('fs'); // lets open files
78 75 var te = require('doubletemplate'); //load double teplate module
79 76 var doubletemplate=te.doubletemplate; // export double template function to global
80 77
81 78 ### example of useing `parsedir` function:
82   - te.parsedir(fs,__dirname+'/templates',{'app':app});
  79 + te.parsedir(__dirname+'/templates',{'app':app});
83 80
84 81 ### example of useing `loadfile` function:
85   - te.loadfile(fs,__dirname+'/templates/filename.html',{'app':app},__dirname);
  82 + te.loadfile(__dirname+'/templates/filename.html',{'app':app},__dirname);
86 83
87 84 ### in the code you can use:
88 85 te.templates['subdir/filename.html']({'app':app});
18 doubletemplate.js
@@ -58,16 +58,14 @@
58 58 //</html>
59 59 //
60 60
  61 +var fs = require('fs'); // lets open files
61 62
62 63 // to include in in nodejs i use:
63   -// // require.paths.unshift(__dirname); //make local paths accecible
64   -// // require('filename') // include file - filename is without '.js' extention!!!
65   -// // var fs = require('fs'); // lets open files
66 64 // var te = require('doubletemplate'); //load double teplate module
67 65 // var doubletemplate=te.doubletemplate; // export double template function to global
68 66
69 67 //example of useing parsedir function:
70   -// te.parsedir(fs,__dirname+'/templates',{'app':app});
  68 +// te.parsedir(__dirname+'/templates',{'app':app});
71 69
72 70 //in the code you use:
73 71 // te.templates['subdir/filename.html']({'app':app});
@@ -295,7 +293,7 @@ function doubletemplate(template,statictata)
295 293 //run recusivly on a directory to load all templates in it.
296 294
297 295 var templates={}; this.templates=templates;
298   -function parsedir(fs,parsedirname,dataobject)
  296 +function parsedir(parsedirname,dataobject)
299 297 {
300 298 //example:
301 299 // te.parsedir(__dirname+'/templates',{'app':app});
@@ -341,7 +339,7 @@ function parsedir(fs,parsedirname,dataobject)
341 339 }this.parsedir=parsedir;
342 340
343 341 /////////
344   -function loadfile(fs,file,dataobject,basedir)
  342 +function loadfile(file,dataobject,basedir)
345 343 {
346 344 if(basedir==null) basedir=dir;
347 345 //example:
@@ -364,4 +362,10 @@ function loadfile(fs,file,dataobject,basedir)
364 362 }
365 363 }
366 364 });
367   -}this.loadfile=loadfile;
  365 +}this.loadfile=loadfile;
  366 +
  367 +/////////
  368 +function loadtemplate(file,dataobject)
  369 +{
  370 + return doubletemplate(fs.readFileSync(file_on_callback),dataobject);
  371 +}this.loadtemplate=loadtemplate;

0 comments on commit 1fc5a95

Please sign in to comment.
Something went wrong with that request. Please try again.