Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I doubt you'll be able to find a gem that will give you this kind of functionality out of the box. Basically, to achieve this, you'll need to write all your views using a DSL that can be translated into either Bootstrap, Zurb, or some other framework.</p> <p>This DSL could be implemented as a series of helper methods in a <a href="http://edgeguides.rubyonrails.org/engines.html" rel="nofollow">Rails Engine</a>.</p> <p>For example, your view could look something like this: (Assuming you use ERB as the templating engine)</p> <pre><code>&lt;%= box do %&gt; &lt;%= header 'Title of the Box' %&gt; &lt;%= body do %&gt; &lt;p&gt;Box content here&lt;/p&gt; &lt;% end %&gt; &lt;% end %&gt; </code></pre> <p>The definitions of these methods could look something like this: (Pseudo-code)</p> <pre><code>def box(options = {}) case EngineName.config.framework.to_sym when :bootstrap klass = '..' # the class you want when :zurb klass = '...' # the class you want end content_tag(:section, class: klass) { yield } end </code></pre> <p>In a <code>config/initializers/framework.rb</code> file, you could configure the engine like so:</p> <pre><code>EngineName.config.framework = :bootstrap # or :zurb </code></pre> <p>There are a few pros and cons with this approach.</p> <h3>Pros</h3> <ul> <li>You can theoretically switch template frameworks without actually having to change your views.</li> </ul> <h3>Cons</h3> <ul> <li>You have to maintain a separate templating DSL in order to abstract away the framework-specific class names and such. This could be time consuming, especially when the frameworks require very different markup to achieve the same result. If you didn't foresee the future markup, you'd end up needing to change your views to support it anyway.</li> </ul> <p>Personally, I think you should consider just going ahead with one framework and not worry about this. It's unlikely that your template DSL would be future-proof, and so creating one could just be unnecessary effort.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload