Sha256: bf46b86e475c2cce52b1075e72b0fd7b5f03b93b0d9f8840a1b29a76fefad72e

Contents?: true

Size: 1.97 KB

Versions: 5

Compression:

Stored size: 1.97 KB

Contents

---
title:  Partials
blurb:  Use partials to keep yourself DRY.
---
<%= md_links %>
<%= md_images %>

<%= current_page.data.blurb %>

_Middlemac_ includes the ability to use partials, that is, bits of Markup, pure
HTML, and/or ERB that can be included in other files, as often as you like.
You might use partials to contain oft-used content. Maybe pieces of a change
log, should you want to present that information to your users in multiple
places. Maybe common warnings that can be included in multiple pages.


Conventions
-----------

Partials should be placed into the correct `partials` directory so that
_Middleman_’s `partial` helper can find them.

Because partials are not rendered into final HTML output files, you should
prefix their filenames with an underscore, and _not_ include `.html` in the
extensions chain.

When using the `partial` helper, _Middleman_ already expects the actual file
to be prefixed with an underscore, therefore you should _not_ include the
underscore when you use the helper.

~~~ erb
<%%= partial 'include_me' %>
~~~

_not_

~~~ erb
<%%= partial '_include_me' %>
~~~

You can pass data to partials as local variable context within the partial.
For example:

~~~ erb
<%%= partial 'hello_world', :locals => { :one => 'Rabbit', :color => 'pink' } %>
~~~

Then, within the code of the partial, you will have local variables `one` and
`color` available to you with their respective values.

These hash key-values use a symbol as a key, and a value as the value for the
key. This is not the same as assigning a value to the Ruby symbol, because the
symbol’s value is simply itself. The hash key is like an `id` object in an
`NSDictionary`. Then when passed to the partial, there will exist a new local
variable using the symbol name. The symbol `:one` becomes the variable `one`
having a string value “pink” in this example.
{: .note .callout}


Examples
--------

Have a look at the **Reference** section, where most of the API information is
added to this project as partials.

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
middlemac-3.1.2 documentation_project/Contents/Resources/en.lproj/040_compose_project/090_partials.html.md.erb
middlemac-3.1.1 documentation_project/Contents/Resources/en.lproj/040_compose_project/090_partials.html.md.erb
middlemac-3.1.0 documentation_project/Contents/Resources/en.lproj/040_compose_project/090_partials.html.md.erb
middlemac-3.0.1 documentation_project/Contents/Resources/en.lproj/040_compose_project/090_partials.html.md.erb
middlemac-3.0.0 documentation_project/Contents/Resources/en.lproj/040_compose_project/090_partials.html.md.erb