Created
January 17, 2013 03:25
Revisions
-
diogofriggo created this gist
Jan 17, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ //Whenever I start a new story there comes the excessive boilerplating that tags along, a series of mini steps //to get you going, one such step is registering your ExtJs controller on App.js, it looks like this: Ext.application name: 'Fidget' autoCreateViewport: true controllers: [ 'YourController', 'HundredsOfOtherControllers' ] //now given my lazyness has caught up with me today, I decided it was time to automate that step //using Embedded Ruby (erb) //File: App.js.coffee.erb Ext.application name: 'Fidget' autoCreateViewport: true controllers: [ <% path = 'app/assets/javascripts/controller' root = "Fidget.controller." controllers = Dir.glob("#{path}/**/*") .select { |file| File.file? file and file.end_with? '.js' } .map { |file| File.read(file) } .map { |file| file.match(/#{root}(?<name>[\w\.]+)/)[:name] } .map { |file| "'#{file}'" } .join(",") %> <%= controllers %> ] //Now, that controllers array will get filled with all the 129 controllers the app has as of today