Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Added support for Express #1

Merged
merged 1 commit into from

3 participants

@lorrenbiffin

Simple 'compile' and 'render' exports added to index. This was done very quickly; please check it out yourself before pulling. :)

@skid skid merged commit 1d04e30 into skid:master
@paularmstrong

This does not work correctly, as it overwrites the ability to set ROOT and DEBUG via the exports.init method. Which, in turn, doesn't allow you to use blocks or includes without a full path.

@lorrenbiffin

I'll take a look at updating the code to cover this use-case (and clean up the other block of merged code) in the next few days (unless someone else can handle it sooner).

@sufianrhazi sufianrhazi referenced this pull request from a commit in sufianrhazi/swig
@paularmstrong paularmstrong Require using end<tagname> like `endif` and `endfor` for all tags.
This update will not be backwards compatible with old-style {% end %} tags. You will need to update all templates.
closes gh-1
c4795ab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 30, 2011
  1. Added support for Express.

    Lorren Biffin authored
This page is out of date. Refresh to see the latest.
Showing with 26 additions and 2 deletions.
  1. +26 −2 index.js
View
28 index.js
@@ -95,5 +95,29 @@ function fromString( string ){
return CACHE[hash] = createTemplate(string, hash);
}
-exports.fromFile = fromFile;
-exports.fromString = fromString;
+
+var nodet = require('node-t');
+
+module.exports = {
+ fromFile: fromFile,
+ fromString: fromString,
+ compile: function (source, options, callback) {
+ self = this;
+ if (typeof source == 'string') {
+ return function(options) {
+ options.locals = options.locals || {};
+ options.partials = options.partials || {};
+ if (options.body) // for express.js > v1.0
+ options.locals.body = options.body;
+ var tmpl = fromString(source);
+ return tmpl.render(options.locals);
+ };
+ } else {
+ return source;
+ }
+ },
+ render: function (template, options) {
+ template = this.compile(template, options);
+ return template(options);
+ }
+};
Something went wrong with that request. Please try again.