Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The main reason this happens is that most MVC platforms generate pages piecemeal, say for example you are generating a 'product' page:

It has a 'template' that contains your header,footer and scripts that everyone relies on.

Then the product piece may also need a script or 2 and finally it may need to add some dynamic love to the page like say: $(myMagicHelper(779,'magic');), in general people are used to just inlining these kind of mini-scripts close to the bit that generates the product html. It can be migrated to a system that defer generates it in the footer, but usually would involve a larger amount of change (at least on projects I worked on). I guess this trick saves you a bit of time migrating some inline scripts to the bottom.



rails has content_for (http://api.rubyonrails.org/classes/ActionView/Helpers/Captur...) that helps with this.


true, still verbose, but more elegant than the solution in asp.net mvc


out of sheer curiosity, what is the asp.net mvc solution?


It doesn't really have one. Annoying, because it's 90% of the way there- views can insert code into specific "sections" of the template, but sub-views can't.

If they just enabled that then you could make a "JS" section just before </body> and have all your JS inserted there.


My current thinking is: http://snipt.org/uNq8




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: