11
Jan
2008
Rails-Tip : Use Capture to wrap a part of View in a variable
The view helper method capture provides this functionality to wrap a section of the view template in a variable and can be used multiple times in the view.
Usage :
Advantage:
If its needed to render a section of template code, we usually go with partials. Capture is specifically useful when partial is only going to be used in just one view template. As there will be this variable available throughout the template, we can use it as many times as needed instead of partial.
Related posts:
- Ruby on Rails Caching And JavaScript Techniques Cross posted from darthsid While implementing caching in a recent...
Related posts brought to you by Yet Another Related Posts Plugin.


Working with Vinsol has been one of the most rewarding and productive collaborations I've ever had in the technology industry. Manik is an intelligent and honest engineer with a great faculty for open and clear communication, and his team include some of the swiftest and keenest developers I've ever had the pleasure to work with. They're great value for money, excellent people who are a joy to know and interact with, and above all they really know their stuff