m0gg / dart-rails

Handle dart scripts for rails so they get compiled to js for browsers without dart support.
MIT License
21 stars 2 forks source link

Writing components #14

Closed Virviil closed 8 years ago

Virviil commented 9 years ago

Would this gem serve HTML temlates and CSS styles for components, made in DART? If yes, could it be added an option to choose my dart app folder. For example, i want to have structure like this: rails_app -app -config -db -... -client --%my_dart_files_with_css_and_html%

m0gg commented 9 years ago

The gem simply enables rails to serve .dart files through the asset pipeline to follow the rails-style.

Usually css and client side scripts belong to the assets because they are static. Rails asset pipeline can be quite a bit tricky. Especially if you make the mistake to include non-static scripts/css. That may work in development mode where the rails-server serves the assets too. Usually rails won't serve assets in production mode. Serving static assets would be the job of the webserver, which should also serve your components. Doing so will make rails unable to automatically compile dart to js, but you can compile them into you components manually before deploying.

Would this gem serve HTML temlates and CSS styles for components, made in DART?

No

Simply serve the components via the webserver, that should be a good solution for your problem.

m0gg commented 9 years ago

I just came up with an idea, are your components pub-packages?

Virviil commented 9 years ago

Well... As for me, Dart today is for either Web components (Polymer components) or for Angular.dart. Or even both. So, when you create app or just a component, it's probably a good practise to have all your component code in one place - html template with css sheets and dart code. When you get polymer components from repositories, they also come with html+css templates, which should be somehow serving during development.

m0gg commented 9 years ago

When you get polymer components from repositories, they also come with html+css templates, which should be somehow serving during development.

I know that, but you've not answered the question above.
Serving components out of pub packages is a cakewalk, as rake pub:get links these packages in app/assets/dart/packages. That's why the asset-pipeline could be able to serve them. If you place assets outside the rails structure, you'll need to configure your asset-pipeline to look there. If you do so, dart-rails will compile your dart-scripts too.