Skip to content

Commit

Permalink
Plate (for the Django template language) seems to have matured, so ad…
Browse files Browse the repository at this point in the history
…ding it back in as a handler. Includes short example.
  • Loading branch information
debrouwere committed Oct 26, 2011
1 parent 6afac4b commit 7f453f4
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions bin/draughtsman
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ var path = require('path');
var fs = require('fs');
var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');

process.title = 'draughtsman';
require(lib + '/command').run();
20 changes: 20 additions & 0 deletions lib/handlers/plate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
(function() {
var context, plate, render_plate;
context = require('../context');
plate = require('plate');
render_plate = function(req, res) {
var template, vars;
vars = context.find_template_variables(req.file.path);
template = new plate.Template(req.file.content);
return template.render(vars, function(err, html) {
res.contentType('text/html');
return res.send(html);
});
};
module.exports = function(app) {
app.accepts.push('plate');
app.accepts.push('dtl');
app.get(/^(.*\.plate)$/, render_plate);
return app.get(/^(.*\.dtl)$/, render_plate);
};
}).call(this);
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"underscore": "latest",
"findit": "0.1.x",
"optimist": "0.2.x",
"http-proxy": "0.7.x"
"http-proxy": "0.7.x",
"plate": "0.x"
},
"repository": {
"type": "git",
Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions test/example/hello.dtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html>
<head>
<link href='style.styl' rel='stylesheet' type='text/css' />
<title>{{ title }}</title>
<body>
<h1>{{ title }}</h1>
<p>description</p>
<script src='script.coffee'></script>
</body>
</html>

0 comments on commit 7f453f4

Please sign in to comment.