<FromGitter>
<eliasjpr> I was wondering how did you managed modularizing amber
<FromGitter>
<eliasjpr> ?
<FromGitter>
<damianham> it is simple - all you have to do is load the modules in the application startup file
<FromGitter>
<damianham> see how it works in the modular recipe
<FromGitter>
<damianham> to modularise a standard amber app you also need to include 'amber_render_module' shard
<FromGitter>
<eliasjpr> I managed to create a directory under src with controllers models and views and require those and run the module as part of the same app
<FromGitter>
<eliasjpr> I was able to do it all manually using the built in render
<FromGitter>
<eliasjpr> Later on I’ll put it on a repo so you can give me you thoughts
<FromGitter>
<damianham> that's interesting - how did you do that ? I found I had to create a new render macro so the views could be found
<FromGitter>
<damianham> OK
<FromGitter>
<eliasjpr> The current render macro takes a path
<FromGitter>
<eliasjpr> I’ll have to publish
<FromGitter>
<eliasjpr> In a few hours I’ll send you the link to the repo
<FromGitter>
<damianham> ah yes but that means you have to modify all the controllers - admittedly not too problematic but I wanted it to work without changing the controller
<FromGitter>
<eliasjpr> I tried to create a macro to inject the modules like rails does it using a ‘mount’ macro but I found that hard since it is compile
<FromGitter>
<eliasjpr> Well I wrapped the controller in a module
<FromGitter>
<eliasjpr> We can build a generator to easy the dev workflow
<FromGitter>
<eliasjpr> What I think it would be great is to be able to create modules as shard lib than can be dropped in to a current amber project
<FromGitter>
<damianham> YES!! that is exactly my thinking and that is why I submitted a PR to allow modular route definition
<FromGitter>
<damianham> the amber_render_module macro uses the path of the controller to find the views so it can be anywhere within the project
<FromGitter>
<damianham> if we amend my PR to also search for route files in lib then that would allow us to drop in modules as shards
feepbot has quit [Ping timeout: 272 seconds]
feepbot has joined #amber
<FromGitter>
<eliasjpr> I don’t think it has to search for routes
<FromGitter>
<eliasjpr> I’ll have to show you
vivus has joined #amber
vivus has quit [Remote host closed the connection]
<FromGitter>
<drujensen> That would be great to drop in a shard and mount it in the routes.
<FromGitter>
<drujensen> Even better if I can keep the MVC pattern in the shard. ;-)
<FromGitter>
<eliasjpr> yes
<FromGitter>
<damianham> No
<FromGitter>
<eliasjpr> thats definitely possible
<FromGitter>
<eliasjpr> lol
<FromGitter>
<eliasjpr> okay
<FromGitter>
<damianham> MVC pattern is broken
<FromGitter>
<drujensen> No it’s not
<FromGitter>
<damianham> :)
<FromGitter>
<damianham> OK - I will accept it is OK for small projects
<FromGitter>
<damianham> not suitable for larger projects
<FromGitter>
<eliasjpr> okay let's not cry over spilled guineas
<FromGitter>
<drujensen> it all depends on the project imo
<FromGitter>
<eliasjpr> They compliment eachother
<FromGitter>
<damianham> if you guys could see the issues I have at the moment with a Rails MVC project with files for 1 feature spread all over the place you would quickly begin to realise modules make more sense
<FromGitter>
<eliasjpr> Modules + MVC = 💓
<FromGitter>
<eliasjpr> @damianham I could say we have the same issue at work
<FromGitter>
<damianham> app/controllers, app/models, app/views, app/assets/javascripts, app/assets/javascripts/backbone/views etc. etc. files in many many places for a singel feature
<FromGitter>
<eliasjpr> @drujensen I have a suprised for the Amber afficionados in regards to params
<FromGitter>
<drujensen> i think the render looks in the views directory
<FromGitter>
<eliasjpr> but you can accomplish the same with the example above I just choose to split it
<FromGitter>
<damianham> so in that folder for the Alarm feature I have alarm.cr (model), *alarm*lib.cr (business logic) and everything else should be self explanatory
<FromGitter>
<damianham> in other modules I also have e.g. src/modules/ais/js/ais.js and all the other javascript code that belongs to the ais module
<FromGitter>
<eliasjpr> @damianham agree, the fact that someone chooses to have sub directory or not is not relevant that a preference
<FromGitter>
<drujensen> I agree as well
<FromGitter>
<damianham> yes Elias you can do that - but with my amber_render_module shard you can skip the path parameter
<FromGitter>
<drujensen> we should see if we can support it
<FromGitter>
<eliasjpr> but what I was trying to demonstrate is that you can accomplish both
<FromGitter>
<damianham> yes I agree you is isn't hard to get what you want from Amber - it was super easy for me to create a modular app
<FromGitter>
<drujensen> can we set some sort of amber setting that allows you to provide the prefix path to the render method?
<FromGitter>
<damianham> no that won't work Dru
<FromGitter>
<drujensen> so if you want mvc, it would be `../views`
<FromGitter>
<eliasjpr> > yes Elias you can do that - but with my amber_render_module shard you can skip the path parameter ⏎ ⏎ Yes. I do prefer not adding another layer if the render method already supports it
<FromGitter>
<drujensen> in the modular it would be `.`
<FromGitter>
<drujensen> why?
<FromGitter>
<damianham> yes OK if you supply a path to every render call - I meant without the path argument
<FromGitter>
<damianham> so controllers as they are
<FromGitter>
<drujensen> this wouldn’t work? `Amber::View.prefix = "."` vs `Amber::View.prefix = "../views"`
<FromGitter>
<drujensen> or instead of project based, what if you just set this in the controller once?
<FromGitter>
<damianham> I don't think that will work for controllers in src/controllers with views in src/views
<FromGitter>
<drujensen> in the base controller for the whole project?
<FromGitter>
<damianham> you still have them in a modular app - e.g home page, signin/signup etc.
<FromGitter>
<drujensen> if you set this per controller, then you can
<FromGitter>
<damianham> src/views/layouts is still the location of the app layout
<FromGitter>
<damianham> as it applies to all modules
<FromGitter>
<drujensen> right, but i’m not following why it wouldn’t work
<FromGitter>
<drujensen> i guess i will try it out when i get a chance
<FromGitter>
<drujensen> see if we can do something to avoid the hard coded path
<FromGitter>
<damianham> yeah that would be great
<FromGitter>
<drujensen> that way we can keep those modular guys happy. ;-)
<FromGitter>
<damianham> :) LOL
<FromGitter>
<drujensen> and the old rails guys will still feel at home
<FromGitter>
<drujensen> lol
<FromGitter>
<damianham> hey if we can add a shard to the shards.yml file and then get a whole new set of routes for our app that will be the most awesome thing
<FromGitter>
<drujensen> yes, totally agree here
<FromGitter>
<drujensen> mount point a shard
<FromGitter>
<eliasjpr> You can do that with the example above