Skip to content

Commit e67ba6b

Browse files
committed
Merge branch 'teacup' of https://github.com/hurrymaplelad/consolidate.js into hurrymaplelad-teacup
2 parents e842211 + 253b661 commit e67ba6b

File tree

6 files changed

+53
-2
lines changed

6 files changed

+53
-2
lines changed

History.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
0.15.0 / 2017-09-18
2+
===================
3+
4+
* add plates support
5+
* add teacup support
6+
17
0.14.0 / 2016-01-24
28
===================
39

Readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
- [react](https://github.com/facebook/react)
4040
- [slm](https://github.com/slm-lang/slm)
4141
- [swig (unmaintained)](https://github.com/paularmstrong/swig)
42+
- [teacup](https://github.com/goodeggs/teacup)
4243
- [templayed](http://archan937.github.com/templayed.js/)
4344
- [twig](https://github.com/justjohn/twig.js)
4445
- [liquid](https://github.com/leizongmin/tinyliquid) [(website)](http://liquidmarkup.org/)

lib/consolidate.js

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,7 +1501,44 @@ exports.marko.render = function(str, options, fn) {
15011501
};
15021502

15031503
/**
1504-
* expose the instance of the engine
1504+
* Teacup support.
15051505
*/
1506+
exports.teacup = function(path, options, fn) {
1507+
return promisify(fn, function(fn) {
1508+
var engine = requires.teacup || (requires.teacup = require('teacup/lib/express'));
1509+
require.extensions['.teacup'] = require.extensions['.coffee'];
1510+
if (path[0] != '/') {
1511+
path = join(process.cwd(), path);
1512+
}
1513+
if (!options.cache) {
1514+
var originalFn = fn;
1515+
fn = function() {
1516+
delete require.cache[path];
1517+
originalFn.apply(this, arguments);
1518+
};
1519+
}
1520+
engine.renderFile(path, options, fn);
1521+
});
1522+
};
15061523

1507-
exports.requires = requires;
1524+
/**
1525+
* Teacup string support.
1526+
*/
1527+
exports.teacup.render = function(str, options, fn){
1528+
var coffee = require('coffee-script');
1529+
var vm = require('vm');
1530+
var sandbox = {
1531+
module: {exports: {}},
1532+
require: require
1533+
};
1534+
return promisify(fn, function(fn) {
1535+
vm.runInNewContext(coffee.compile(str), sandbox);
1536+
var tmpl = sandbox.module.exports;
1537+
fn(null, tmpl(options));
1538+
});
1539+
}
1540+
1541+
/**
1542+
* expose the instance of the engine
1543+
*/
1544+
exports.requires = requires;

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"babel-core": "^6.7.6",
1919
"babel-preset-react": "^6.5.0",
2020
"bracket-template": "^1.0.3",
21+
"coffee-script": "^1.11.1",
2122
"dot": "^1.0.1",
2223
"dust": "^0.3.0",
2324
"dustjs-helpers": "^1.1.1",
@@ -55,6 +56,7 @@
5556
"should": "*",
5657
"slm": "^0.5.0",
5758
"swig": "^1.4.1",
59+
"teacup": "^2.0.0",
5860
"templayed": ">=0.2.3",
5961
"tinyliquid": "^0.2.22",
6062
"toffee": "^0.1.12",

test/consolidate.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@ require('./shared/includes').test('arc-templates');
5353
require('./shared/partials').test('arc-templates');
5454
require('./shared').test('marko');
5555
require('./shared').test('bracket');
56+
require('./shared').test('teacup');

test/fixtures/teacup/user.teacup

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{renderable, p} = require 'teacup'
2+
3+
module.exports = renderable ({user}) ->
4+
p user.name

0 commit comments

Comments
 (0)