Permalink
Browse files

Convert to pure CoffeeScript project.

  • Loading branch information...
1 parent 13b412e commit b1b98b478438a5367a6f866a94b8d6d566b28db4 @netzpirat committed Aug 20, 2012
Showing with 2 additions and 1,700 deletions.
  1. +0 −1 Guardfile
  2. +2 −7 bin/haml-coffee
  3. +0 −63 lib/cli/coffee-maker.js
  4. +0 −149 lib/cli/command.js
  5. +0 −423 lib/haml-coffee.js
  6. +0 −61 lib/hamlc.js
  7. +0 −49 lib/nodes/code.js
  8. +0 −43 lib/nodes/comment.js
  9. +0 −130 lib/nodes/filter.js
  10. +0 −513 lib/nodes/haml.js
  11. +0 −192 lib/nodes/node.js
  12. +0 −26 lib/nodes/text.js
  13. +0 −43 lib/util/text.js
View
@@ -1,6 +1,5 @@
interactor :simple
-guard :coffeescript, :input => 'src', :output => 'lib'
guard :coffeescript, :input => 'dist/helpers', :output => 'dist/helpers'
guard 'process', :name => 'Jasmine specs', :command => 'jasmine-node --coffee --color spec/compiler_spec.coffee' do
View
@@ -1,7 +1,2 @@
-#!/usr/bin/env node
-
-var path = require('path');
-var fs = require('fs');
-var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');
-
-require(lib + '/cli/command').run();
+#!/usr/bin/env coffee
+require('./../src/cli/command').run()
@@ -1,63 +0,0 @@
-(function() {
- var CoffeeMaker, CoffeeScript, HamlCoffee, fs;
-
- CoffeeScript = require('coffee-script');
-
- HamlCoffee = require('../haml-coffee');
-
- fs = require('fs');
-
- module.exports = CoffeeMaker = (function() {
-
- function CoffeeMaker() {}
-
- CoffeeMaker.compileFile = function(filename, compilerOptions, namespace, templateName) {
- var compiler, haml, output, source, _ref;
- if (compilerOptions == null) {
- compilerOptions = {};
- }
- if (namespace == null) {
- namespace = null;
- }
- if (templateName == null) {
- templateName = null;
- }
- output = '';
- try {
- source = fs.readFileSync(filename).toString();
- } catch (error) {
- console.error(' \x33[91mError opening file:\x33[0m %s', error);
- console.error(error);
- }
- try {
- if (!templateName) {
- templateName = (_ref = filename.match(/([^\.]+)(\.html)?\.haml[c]?$/)) != null ? _ref[1] : void 0;
- }
- if (templateName) {
- compiler = new HamlCoffee(compilerOptions);
- compiler.parse(source);
- haml = compiler.render(templateName, namespace);
- } else {
- console.error(' \x33[91m[haml coffee] no valid Haml extension.\x33[0m');
- process.exit(1);
- }
- } catch (error) {
- console.error(' \x33[91m[haml coffee] error compiling Haml file:\x33[0m %s', error);
- console.error(error.stack);
- process.exit(1);
- }
- try {
- output = CoffeeScript.compile(haml);
- } catch (error) {
- console.error(' \x33[91m[haml coffee] CoffeeScript compilation error:\x33[0m %s', error);
- console.error(error.stack);
- process.exit(1);
- }
- return output;
- };
-
- return CoffeeMaker;
-
- })();
-
-}).call(this);
View
@@ -1,149 +0,0 @@
-(function() {
- var CoffeeMaker, argv, findit, fs;
-
- CoffeeMaker = require('./coffee-maker');
-
- fs = require('fs');
-
- findit = require('findit');
-
- argv = require('optimist').usage('Usage: $0').options('i', {
- alias: 'input',
- demand: true,
- describe: 'Either a file or a directory name to be compiled'
- }).options('o', {
- alias: 'output',
- describe: 'Set the output filename'
- }).options('n', {
- alias: 'namespace',
- describe: 'Set a custom template namespace',
- "default": 'window.HAML'
- }).options('t', {
- alias: 'template',
- describe: 'Set a custom template name'
- }).options('b', {
- alias: 'basename',
- boolean: true,
- "default": false,
- describe: 'Ignore file path when generate the template name'
- }).options('f', {
- alias: 'format',
- "default": 'html5',
- describe: 'Set HTML output format, either `xhtml`, `html4` or `html5`'
- }).options('u', {
- alias: 'uglify',
- boolean: true,
- "default": false,
- describe: 'Do not properly indent or format the HTML output'
- }).options('e', {
- alias: 'extend',
- boolean: true,
- "default": false,
- describe: 'Extend the template scope with the context'
- }).options('preserve', {
- "default": 'pre,textarea',
- describe: 'Set a comma separated list of HTML tags to preserve'
- }).options('autoclose', {
- "default": 'meta,img,link,br,hr,input,area,param,col,base',
- describe: 'Set a comma separated list of self-closed HTML tags'
- }).options('disable-html-attribute-escaping', {
- boolean: true,
- describe: 'Disable any HTML attribute escaping'
- }).options('disable-html-escaping', {
- boolean: true,
- describe: 'Disable any HTML escaping'
- }).options('disable-clean-value', {
- boolean: true,
- describe: 'Disable any CoffeeScript code value cleaning'
- }).options('custom-html-escape', {
- "default": '',
- describe: 'Set the custom HTML escaping function name'
- }).options('custom-preserve', {
- "default": '',
- describe: 'Set the custom preserve whitespace function name'
- }).options('custom-find-and-preserve', {
- "default": '',
- describe: 'Set the custom find and preserve whitespace function name'
- }).options('custom-clean-value', {
- "default": '',
- describe: 'Set the custom code value clean function name'
- }).options('custom-surround', {
- "default": '',
- describe: 'Set the custom surround function name'
- }).options('custom-succeed', {
- "default": '',
- describe: 'Set the custom succeed function name'
- }).options('custom-precede', {
- "default": '',
- describe: 'Set the custom precede function name'
- }).argv;
-
- exports.run = function() {
- var compilerOptions, inputFilename, namespace, templateName;
- if (['xhtml', 'html4', 'html5'].indexOf(argv.f) === -1) {
- throw "Unknown template format '" + argv.f + "'";
- }
- inputFilename = argv.i;
- templateName = argv.t;
- namespace = argv.n;
- compilerOptions = {
- format: argv.f,
- uglify: argv.u,
- extendScope: argv.e,
- preserveTags: argv.preserve,
- escapeHtml: !argv['disable-html-escaping'],
- escapeAttributes: !argv['disable-html-attribute-escaping'],
- cleanValue: !argv['disable-clean-value'],
- customHtmlEscape: argv['custom-html-escape'],
- customCleanValue: argv['custom-clean-value'],
- customFindAndPreserve: argv['custom-find-and-preserve'],
- customPreserve: argv['custom-preserve'],
- customSurround: argv['custom-surround'],
- customSucceed: argv['custom-succeed'],
- customPrecede: argv['custom-precede'],
- basename: argv['basename']
- };
- return fs.stat(inputFilename, function(err, stat) {
- var baseDir, compound, filename, outputFilename, _i, _len, _ref, _ref1, _ref2;
- if (!err) {
- if (!stat.isDirectory()) {
- outputFilename = argv.o || ("" + ((_ref = argv.i.match(/([^\.]+)(\.html)?\.haml[c]?$/)) != null ? _ref[1] : void 0) + ".jst");
- console.error(' \x33[90m[Haml Coffee] Compiling file\x33[0m %s to %s', inputFilename, outputFilename);
- fs.writeFileSync(outputFilename, CoffeeMaker.compileFile(inputFilename, compilerOptions, namespace, templateName));
- return process.exit(0);
- } else {
- if (templateName) {
- console.error(' \x33[91m[Haml Coffee] You can\'t compile all Haml templates in a directory and give a single template name!\x33[0m');
- process.exit(1);
- }
- console.log(' \x33[92m[Haml Coffee] Compiling directory\x33[0m %s', inputFilename);
- baseDir = inputFilename.replace(/\/$/, '');
- compound = '';
- _ref1 = findit.sync(baseDir);
- for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
- filename = _ref1[_i];
- if (filename.match(/([^\.]+)(\.html)?\.haml[c]?$/)) {
- if (argv.o) {
- console.log(' \x33[90m[Haml Coffee] Compiling file\x33[0m %s', filename);
- compound += CoffeeMaker.compileFile(filename, compilerOptions, namespace);
- } else {
- outputFilename = "" + ((_ref2 = filename.match(/([^\.]+)(\.html)?\.haml[c]?$/)) != null ? _ref2[1] : void 0) + ".jst";
- console.log(' \x33[90m[Haml Coffee] Compiling file\x33[0m %s to %s', inputFilename, outputFilename);
- fs.writeFileSync(outputFilename, CoffeeMaker.compileFile(filename, compilerOptions));
- }
- }
- }
- if (argv.o) {
- console.log(' \x33[90m[Haml Coffee] Writing all templates to\x33[0m %s', argv.o);
- fs.writeFileSync(argv.o, compound);
- }
- return process.exit(0);
- }
- } else {
- console.error(' \x33[91m[Haml Coffee] Error compiling file\x33[0m %s: %s', argv.i, err);
- return process.exit(1);
- }
- });
- };
-
-}).call(this);
Oops, something went wrong.

0 comments on commit b1b98b4

Please sign in to comment.