From bfd74f5ecfe550e9766ce89b24ea71111c950668 Mon Sep 17 00:00:00 2001 From: Dustin Specker Date: Sat, 9 Aug 2014 20:01:57 -0500 Subject: [PATCH] (feat) HAML support --- app/index.js | 4 ++ app/templates/_gulpfile.js | 58 +++++++++++++++++++++-------- app/templates/_index.haml | 19 ++++++++++ app/templates/_package.json | 2 + app/templates/karma.config.js | 4 ++ directive/templates/_directive.haml | 1 + element/templates/_element.haml | 8 ++++ test/test-creation.js | 2 +- view/templates/_view.haml | 2 + 9 files changed, 83 insertions(+), 17 deletions(-) create mode 100644 app/templates/_index.haml create mode 100644 directive/templates/_directive.haml create mode 100644 element/templates/_element.haml create mode 100644 view/templates/_view.haml diff --git a/app/index.js b/app/index.js index 694e831..947f179 100644 --- a/app/index.js +++ b/app/index.js @@ -29,6 +29,10 @@ Generator.prototype.prompting = function prompting() { name: 'markup', message: 'What is the preferred markup language?', choices: [ + { + name: 'HAML', + value: 'haml' + }, { name: 'HTML', value: 'html' diff --git a/app/templates/_gulpfile.js b/app/templates/_gulpfile.js index cce089f..d1c6912 100644 --- a/app/templates/_gulpfile.js +++ b/app/templates/_gulpfile.js @@ -8,6 +8,7 @@ var gulp = require('gulp') , concat = require('gulp-concat') , cssmin = require('gulp-cssmin') , gulpIf = require('gulp-if') + , haml = require('gulp-haml') , htmlmin = require('gulp-htmlmin') , inject = require('gulp-inject') , jade = require('gulp-jade') @@ -34,13 +35,13 @@ var _ = require('lodash') // app src locations var appBase = 'app/' - , appMarkupFiles = appBase + '**/*.{html,jade}' + , appMarkupFiles = appBase + '**/*.{haml,html,jade}' , appScriptFiles = appBase + '**/*.js' , appStyleFiles = appBase + '**/*.{less,scss,styl}'; <% if (polymer) { %>// custom component locations var componentsBase = appBase + 'components/' - , componentsMarkupFiles = componentsBase + '**/*.{html,jade}' + , componentsMarkupFiles = componentsBase + '**/*.{haml,html,jade}' , componentsScriptFiles = componentsBase + '**/*.js' , componentsStyleFiles = componentsBase + '**/*.{less,scss,styl}'; @@ -158,20 +159,28 @@ gulp.task('jshint', function () { <% if (polymer) { %>gulp.task('components', ['clean', 'jshint'], function () { var stream = streamqueue({ objectMode: true }); - // jade + // haml stream.queue(gulp.src([ componentsMarkupFiles, - '!**/*.html' + '!**/*.{html,jade}' ], { base: componentsBase }) - .pipe(jade())) + .pipe(haml())) ; // html stream.queue(gulp.src([ componentsMarkupFiles, - '!**/*.jade' + '!**/*.{haml,jade}' ], { base: componentsBase })); + // jade + stream.queue(gulp.src([ + componentsMarkupFiles, + '!**/*.{haml,html}' + ], { base: componentsBase }) + .pipe(jade())) + ; + // js stream.queue(gulp.src( componentsScriptFiles @@ -275,19 +284,36 @@ gulp.task('style', ['clean'], function () { }); gulp.task('markup', ['clean'], function () { - return gulp.src([ + var stream = streamqueue({ objectMode: true }); + + // haml + stream.queue(gulp.src([ + appMarkupFiles,<% if (polymer) { %>, + '!' + componentsBase + '**/*'<% } %>, + '!**/*.{html,jade}' + ]) + .pipe(haml())) + ; + + // html + stream.queue(gulp.src([ appMarkupFiles<% if (polymer) { %>, '!' + componentsBase + '**/*'<% } %>, - '!**/*.html' + '!**/*.{haml,jade}' + ])); + + // jade + stream.queue(gulp.src([ + appMarkupFiles<% if (polymer) { %>, + '!' + componentsBase + '**/*'<% } %>, + '!**/*.{haml,html}' ]) - .pipe(jade()) - .pipe(addSrc([ - appMarkupFiles<% if (polymer) { %>, - '!' + componentsBase + '**/*'<% } %>, - '!**/*.jade' - ])) - .pipe(gulp.dest(build)) + .pipe(jade())) ; + + return stream.done() + .pipe(gulp.dest(build)); + }); gulp.task('inject', [<% if (polymer) { %>'components', <% } %>'markup', 'scripts', 'style'], function () { @@ -347,7 +373,7 @@ gulp.task('inject', [<% if (polymer) { %>'components', <% } %>'markup', 'scripts stream.queue(gulp.src([ bowerDir + 'angular/angular.js', bowerDir + 'angular-mocks/angular-mocks.js', - appBase + '**/*-directive.tpl.{html,jade}' + appBase + '**/*-directive.tpl.{haml,html,jade}' ])); stream.queue(gulp.src([ diff --git a/app/templates/_index.haml b/app/templates/_index.haml new file mode 100644 index 0000000..24063c0 --- /dev/null +++ b/app/templates/_index.haml @@ -0,0 +1,19 @@ +!!! 5 +%html{lang: "en", data-ng-app: "<%= appName %>"} + %head + %title <%= appName %> + %meta{name: "viewport", content: "width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"} + + + + + + + %body + +
+ + + + + \ No newline at end of file diff --git a/app/templates/_package.json b/app/templates/_package.json index d3647f0..31899d7 100644 --- a/app/templates/_package.json +++ b/app/templates/_package.json @@ -15,6 +15,7 @@ "gulp-coffeelint": "^0.3.3", "gulp-concat": "^2.3.4", "gulp-cssmin": "^0.1.6", + "gulp-haml": "^0.1.0", "gulp-htmlmin": "^0.1.3", "gulp-if": "^1.2.4", "gulp-inject": "^0.4.1", @@ -34,6 +35,7 @@ "karma-coverage": "^0.2.5", "karma-failed-reporter": "^0.0.2", "karma-jasmine": "^0.1.5", + "karma-ng-haml2js-preprocessor": "git://github.com/codysims/karma-ng-haml2js-preprocessor.git", "karma-ng-html2js-preprocessor": "^0.1.0", "karma-ng-jade2js-preprocessor": "^0.1.3", "karma-phantomjs-launcher": "^0.1.4", diff --git a/app/templates/karma.config.js b/app/templates/karma.config.js index 385f003..e3c6f6e 100644 --- a/app/templates/karma.config.js +++ b/app/templates/karma.config.js @@ -6,10 +6,14 @@ module.exports = { reporters: ['failed', 'coverage'], preprocessors: { 'app/**/!(*_test)+(.js)': ['coverage'], + 'app/**/*-directive.tpl.haml': ['ng-haml2js'], 'app/**/*-directive.tpl.html': ['ng-html2js'], 'app/**/*-directive.tpl.jade': ['ng-jade2js'], '**/*_test.coffee': ['coffee'] }, + ngHaml2JsPreprocessor: { + 'stripPrefix': 'app/' + }, ngHtml2JsPreprocessor: { 'stripPrefix': 'app/' }, diff --git a/directive/templates/_directive.haml b/directive/templates/_directive.haml new file mode 100644 index 0000000..20d531e --- /dev/null +++ b/directive/templates/_directive.haml @@ -0,0 +1 @@ +%div \ No newline at end of file diff --git a/element/templates/_element.haml b/element/templates/_element.haml new file mode 100644 index 0000000..2189007 --- /dev/null +++ b/element/templates/_element.haml @@ -0,0 +1,8 @@ +%link{rel: "import", href: "../polymer/polymer.html"} + +%polymer-element{name: "<%= hyphenName %>"} + %template + %link{rel: "stylesheet", href: "<%= hyphenName %>.css"} + %div {{name}} + + %script{src: "<%= hyphenName %>.js"} \ No newline at end of file diff --git a/test/test-creation.js b/test/test-creation.js index f62a7d9..8918943 100644 --- a/test/test-creation.js +++ b/test/test-creation.js @@ -103,7 +103,7 @@ describe('ng-poly generator', function () { }, { 'appName': 'temp3', - 'markup': 'jade', + 'markup': 'haml', 'appScript': 'js', 'controllerAs': true, 'passFunc': true, diff --git a/view/templates/_view.haml b/view/templates/_view.haml new file mode 100644 index 0000000..bde8101 --- /dev/null +++ b/view/templates/_view.haml @@ -0,0 +1,2 @@ +%h2 <%= lowerCamel %> +%p {{<% if (controllerAs) { %><%= lowerCamel %>.<% } %>ctrlName}} \ No newline at end of file