-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 83b5b5c
Showing
4 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<Response> | ||
<: body :> | ||
</Response> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |