-
Notifications
You must be signed in to change notification settings - Fork 1
Tags Partial
Partial tags are perhaps the simplest WIllow tag to understand and use, as they are not passed by the parser, they take the following format:
{> partial <}
Partials are simply re-usable collections of html or javascript, such as a button or a call to action, they can contain other tags and are parsed by Willow before being rendered.
Partials are stored as text files with a .willow extension - here is an example from one of our Q Themes:
{> search_trigger <}
library/willow/partial/partial~search_trigger.willow
<div class="row ml-0">
<div class="col-12 list-group list-group-flush border-top">
<div class="list-group-item">
You can also
<a
class="ml-1 btn btn-primary text-white p-2 q-scroll-top"
data-toggle="collapse"
data-target="#search_content"
aria-controls="search_content"
aria-expanded="false"
aria-label="Search navigation"
href="#">
Search our Work
</a>
</div>
</div>
</div>
When you call a Partial, Willow simply looks for a matching stored configuration file and returns the data, as shown below:
file: q-willow/library/context/partial.php
function get( $args = null ) {
return $config->get([ 'context' => $args['context'], 'task' => $args['task'] ]);
}
If no matching context/task pair is found, no data will be returned and the partial will render nothing, being removed from the template by the parser cleanup process.
The location of the partial file is important due to how the configuration lookups work - read more