yaymukund / grunt-ember-handlebars

Precompile ember templates in grunt using only headless-ember.js and ember.js
MIT License
34 stars 26 forks source link

support for compiling ember components #20

Open dlai0001 opened 11 years ago

dlai0001 commented 11 years ago

Allows you to specify a componentsRegEx that'll prefix components with 'components/' in the template name so they can be used as Ember Components.

dlai0001 commented 11 years ago

I think I might of have some sort of auto convert tabs to spaces that makes the change bigger than it really is. Most of it is just a change from a conditional that switched between a partial and a normal template to a if/else if/else block that also support components.

//process var name/namespace of template.
+                    if (isPartial.test(_.last(filepath.split('/'))) ) {
+                        filename = processPartialName(filepath);
+                        templates.push(nsInfo.namespace+'['+JSON.stringify(filename)+'] = '+compiled+';');
+                    } else if(isComponent.test(filepath)){
+                        filename = processName(filepath);
+                        templates.push(nsInfo.namespace + "[" + JSON.stringify( 'components/' + filename)+"] = " +compiled+';');
+                    } else {
+                        filename = processName(filepath);
+                        templates.push(nsInfo.namespace +'['+JSON.stringify(filename)+'] = '+compiled+';');
+                    }