Skip to content
Terry Wilson edited this page Sep 17, 2014 · 1 revision

f7_view - View Container

This renders a container for a single view.

If you will be loading these entire views via AJAX, this will effectively be the layout for a controller.

Would be best to us this helper to construct the templates that are populated by AJAX requests, rather than constantly serving bloated views.

Usage

f7_view name, &block
f7_view name, html_options, &block
f7_view name, html_options

Examples

With a block

Without options

Input
<%= f7_view 'main' do %>
    <!-- Other Content -->
<% end %>
Output
<div class="view view-main">
    <!-- Other Content -->
</div>

With html_options

Whilst not required, you can specify additional html options, such as an id or additional CSS classes.

Input
<%= f7_view 'main', :id => :test, :class => 'demo' do %>
    <!-- Other Content -->
<% end %>
Output
<div id="test" class="view view-main demo">
    <!-- Other Content -->
</div>

Without a block

If you choose not to pass a block along with this helper it will attempt to load a partial as follows:

app/views/<controller>/<view>/<view>

For example, if you have a WelcomeController view containing the following markup:

    <%= f7_view :main %>

It will try and load the partial app/views/welcome/main/main, obeying the normal rules for file extensions, etc. failing if it cannot be found.


Framework7 Documentation

View