Created
August 18, 2013 03:35
-
-
Save danfinlay/6259778 to your computer and use it in GitHub Desktop.
How does one use trumpet to inject a series of individual files into a page? I feel like the asynchronous nature of streams means these extensions may be loaded unreliably, is there a more correct way?
This file contains hidden or 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
| fs.createServer(function(req, res){ | |
| var extensionTrumpet = trumpet(); | |
| extensionTrumpet.selectAll('#frameInitScript', function(elem){ | |
| var writeOutStream = elem.createWriteStream(); | |
| for(var i = 0; i < extensions.length; i++){ | |
| fs.createReadStream(__dirname + '/../site/blocks/'+extensions[i]+'.js').pipe(writeOutStream); | |
| } | |
| }); | |
| fs.createReadStream(__dirname+'/../site/frame.html') | |
| .pipe(extensionTrumpet).pipe(res); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment