0

# New to flask!

I'm working on adding features to a Flask project and it has its assets bundled using the code below in __init__.py file.

js = Bundle('javascripts/leaflet-src.js',
            'javascripts/leaflet.markercluster-src.js',
            'javascripts/handlebars-v3.0.3.js',
            'javascripts/Control.Geocoder.js','javascripts/Control.LinkButton.js',
            'javascripts/underscore-min.js','javascripts/L.Control.Sidebar.js',
            'javascripts/Control.Loading.js', 'javascripts/main.js',
            filters='jsmin',
            output='gen/packed.js')

I'm gonna add more javascript files and this will keep growing and my __init__.py looks ugly.

I work a lot with Ruby in Rails and I like the way assets are managed there. You have an application.js.erb file where you add all the js file names that you want to be included into one application.js file. I could build one such structure for this Flask project too but I would like to know whether there is already a nicer way to manage growing assets in Flask.

aBadAssCowboy
  • 2,440
  • 2
  • 23
  • 38
  • Not being familiar with how Rails does this, is your concern the need for quotes and commas? I imagine `application.js.rb` would grow just the same. – dirn May 14 '16 at 09:37
  • Sure! However, `application.js.erb` will have only the asset file names but nothing else. In flask, the `Bundle` function call is in the `__init__.py` file which also has quite some other logic. I will update the question to reflect my concerns properly. – aBadAssCowboy May 14 '16 at 09:41

0 Answers0