Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
thecolorblue committed Apr 15, 2011
0 parents commit 83b5b5c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
Empty file added README
Empty file.
4 changes: 4 additions & 0 deletions page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<: body :>
</Response>
4 changes: 4 additions & 0 deletions test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Say>{content}</Say>
</Response>
38 changes: 38 additions & 0 deletions twillio-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Twillio App
* Quick little app for setting meetings
*
*/

var http = require('http');
var meryl = require('meryl');
var dust = require('dust');
var fs = require('fs');
meryl.handle('GET /',function(req,res){
fs.readFile('./page.html',encoding='utf8',function(err,data){
if(err) console.log(err);
node = {
title:'<div>Title goes here</div>',
body:'<Say voice="woman" loop="2">Hello</Say>'
}
substitute(data,node,function(html){
res.setHeader("Content-Type", "text/xml");
res.end(html);
console.log(html);
});
});
});
function substitute(string,array,callback){
var re = /<:\s(\w+)\s:>/g;
var searchString = string;
var result = searchString.match(re);
for (i = 0;i<result.length;i++){
var reg = /\s(\w+)\s/;
var tarray = reg.exec(result[i]);
var templateName = tarray[1];
var replacement = array[templateName];
searchString = searchString.replace(result[i],replacement);
}
callback(searchString);
}
meryl.run();

0 comments on commit 83b5b5c

Please sign in to comment.