You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.6 KiB

  1. // Generated by CoffeeScript 1.4.0
  2. var __hasProp = {}.hasOwnProperty,
  3. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  4. module.exports = function(BasePlugin) {
  5. var Html2coffeePlugin;
  6. return Html2coffeePlugin = (function(_super) {
  7. __extends(Html2coffeePlugin, _super);
  8. function Html2coffeePlugin() {
  9. return Html2coffeePlugin.__super__.constructor.apply(this, arguments);
  10. }
  11. Html2coffeePlugin.prototype.name = 'html2coffee';
  12. Html2coffeePlugin.prototype.renderHTMLToCoffee = function(opts, next) {
  13. var content, html2coffee, outputStream, templateData;
  14. templateData = opts.templateData, content = opts.content;
  15. html2coffee = require('html2coffeekup');
  16. outputStream = {
  17. content: '',
  18. write: function(data) {
  19. return this.content += data;
  20. }
  21. };
  22. return html2coffee.convert(content, outputStream, function(err) {
  23. if (err) {
  24. return next(err);
  25. }
  26. opts.content = outputStream.content;
  27. return next();
  28. });
  29. };
  30. Html2coffeePlugin.prototype.render = function(opts, next) {
  31. var inExtension, outExtension;
  32. inExtension = opts.inExtension, outExtension = opts.outExtension;
  33. if (inExtension === 'html' && outExtension === 'coffee') {
  34. return this.renderHTMLToCoffee(opts, next);
  35. } else {
  36. return next();
  37. }
  38. };
  39. return Html2coffeePlugin;
  40. })(BasePlugin);
  41. };