Created
June 22, 2011 20:26
-
-
Save danielbeardsley/1041060 to your computer and use it in GitHub Desktop.
A template renderer for express.js that processes plain vanilla HTML and has the option to strip newlines.
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
// Usage: | |
// express_app.register('html', htmlRenderer({stripNewlines: true})); | |
// ... | |
// express_app.get('/plain', function(req, res){ | |
// res.render('./path_to_html_file'); | |
// }) | |
function htmlRenderer(opt){ | |
var stripNewlines = opt && opt.stripNewlines; | |
return { | |
compile: function(str, view_options){ | |
if(stripNewlines) str = str.replace(/[\n\r]+/, ' '); | |
return function(locals){ | |
return str; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment