Skip to content

Commit

Permalink
(feat) HAML support
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinspecker committed Aug 10, 2014
1 parent 8e1030a commit bfd74f5
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 17 deletions.
4 changes: 4 additions & 0 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
58 changes: 42 additions & 16 deletions app/templates/_gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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}';

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 () {
Expand Down Expand Up @@ -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([
Expand Down
19 changes: 19 additions & 0 deletions app/templates/_index.haml
Original file line number Diff line number Diff line change
@@ -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"}
<!-- inject:head:js -->
<!-- endinject -->
<!-- inject:html -->
<!-- endinject -->
<!-- inject:css -->
<!-- endinject -->
%body
<div data-ui-view></div>
<!-- inject:js -->
<!-- endinject -->
<!-- inject:angular:js -->
<!-- endinject -->
2 changes: 2 additions & 0 deletions app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions app/templates/karma.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/'
},
Expand Down
1 change: 1 addition & 0 deletions directive/templates/_directive.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
%div
8 changes: 8 additions & 0 deletions element/templates/_element.haml
Original file line number Diff line number Diff line change
@@ -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"}
2 changes: 1 addition & 1 deletion test/test-creation.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('ng-poly generator', function () {
},
{
'appName': 'temp3',
'markup': 'jade',
'markup': 'haml',
'appScript': 'js',
'controllerAs': true,
'passFunc': true,
Expand Down
2 changes: 2 additions & 0 deletions view/templates/_view.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
%h2 <%= lowerCamel %>
%p {{<% if (controllerAs) { %><%= lowerCamel %>.<% } %>ctrlName}}

0 comments on commit bfd74f5

Please sign in to comment.