-
Notifications
You must be signed in to change notification settings - Fork 448
Including One Pattern Within Another
To use one pattern within another, for example to create a molecule from several atoms, you can either use:
- a shorthand partials syntax or
- the default Mustache partials syntax.
The shorthand partials syntax mimics the format that was found in the inc()
function from the original version of Pattern Lab. It allows for partials to be less verbose than the default Mustache partials syntax. The shorthand syntax uses the following format:
{{> [patternType]-[patternName] }}
For example, let's say we wanted to include the following pattern in a molecule:
atoms/images/landscape-16x9.mustache
The pattern type is atoms
and the pattern name is landscape-16x9
. Pattern sub-types are never used in this format. The shorthand partial syntax would be:
{{> atoms-landscape-16x9 }}
The shorthand syntax also allows for fuzzy matching on pattern names. This means that, if you feel your pattern name is going to be unique within a given pattern type, you can supply just the unique part of the pattern name and the partial will be included correctly. For example, using the shorthand syntax this partial could be written as:
{{> atoms-16x9 }}
Important: If you include 16x9
in another pattern the PHP version of Pattern Lab may find that first depending on how your patterns are organized.
The PHP version of Pattern Lab also supports the default Mustache partials syntax if you need more specificity when adding partials to your templates. The syntax is simply the path to the partial minus the .mustache
extension. For example, let's say we wanted to include the following pattern in a molecule:
atoms/images/landscape-16x9.mustache
The default Mustache partial syntax would be:
{{> atoms/images/landscape-16x9 }}