There are two ways to do this. Using partial or using content_for block :
If the “Text” was longer or was a significant subtree, you could extract it in partial. This will slightly reduce your code. In the above example, this may seem redundant.
The best way in this case would be to use a content_for block, for example:
- if !request.path_info.include? 'A'
%{:id => 'A'}
=yield :content
- else
=yield :content
-content_for :content do
Text
content_for , "". , .