// Generated by CoffeeScript 1.12.4
(function() {
  var INCLUDE, fs, includeDirective, includeReplace, path;

  fs = require('fs');

  path = require('path');

  INCLUDE = /( *)<!-- include\((.*)\) -->/gmi;

  includeReplace = function(includePath, match, spaces, filename) {
    var content, fullPath, lines;
    fullPath = path.join(includePath, filename);
    lines = fs.readFileSync(fullPath, 'utf-8').replace(/\r\n?/g, '\n').split('\n');
    content = spaces + lines.join("\n" + spaces);
    return includeDirective(path.dirname(fullPath), content);
  };

  includeDirective = function(includePath, input) {
    return input.replace(INCLUDE, includeReplace.bind(this, includePath));
  };

  exports.includeDirective = includeDirective;

  exports.expand = function(file) {
    return includeDirective(path.dirname(file), fs.readFileSync(file, 'utf-8'));
  };

}).call(this);
