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
| depends on http://github.com/mikeal/watch |
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
| function HttpBodyServer( callback ) { | |
| return http.createServer( function( request, response ) { | |
| var body = ''; | |
| request.on( 'data', function( chunk ) { | |
| body += chunk.toString( ); | |
| } ); | |
| request.on( 'end', function( ) { | |
| callback( request, response, body ); | |
| } ); | |
| } ); |
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
| var http = require( 'http' ), | |
| parse = require( 'querystring' ).parse; | |
| http.createServer( function( request, response ) { | |
| var body = ''; | |
| request.on( 'data', function( chunk ) { | |
| body += chunk.toString( ); | |
| } ); | |
| request.on( 'end', function( ) { | |
| console.info( parse( body ) ); |
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
| function template( targetNode, templateNode_ ) { | |
| var self = {}; | |
| var templateNode = templateNode_ || targetNode; | |
| var templateString = $( templateNode ).innerHTML.replace( /^\s*<!--/, '' ).replace( /-->\s*$/, '' ); | |
| targetNode.innerHTML = ''; | |
| self.render = function( data ) { | |
| targetNode.innerHTML = Mustache.to_html( templateString, data ); | |
| return data; | |
| }; | |
| return self; |
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
| {{#a_object}} | |
| <h1>{{title}}</h1> | |
| <p>{{description}}</p> | |
| <ul> | |
| {{#a_list}} | |
| <li>{{label}}</li> | |
| {{/a_list}} | |
| </ul> | |
| {{/a_object}} |
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
| diff --git a/mustache.js b/mustache.js | |
| index 58e6460..1fba949 100644 | |
| --- a/mustache.js | |
| +++ b/mustache.js | |
| @@ -118,6 +118,8 @@ var Mustache = function() { | |
| return that.render(content, that.merge(context, | |
| that.create_context(row)), partials, true); | |
| }).join(""); | |
| + } else if(that.is_object(value)) { // Object, Use it as subcontext! | |
| + return that.render(content, that.merge(context, that.create_context(value)), partials, true); |
NewerOlder