How to Make Global Partials

I would like to suggest a global partials feature, so you can access partials from another plugin or from the theme. The basic usage would be an option to have an ui component library / plugin.

I develop a website which has a lot of custom stuff and so I split all the work to multiple plugins.

However, since the design elements often include similar things, I have to rebuild the ui components quite often.

I asked this earlier if there’s a possibility to do this and got a no, so I would definitly suggest to add a feature here, it would make work a lot easier :smiley:

How to make a global partial

  1. Create a view file in the views directory. Eg: plugins/acme/demo/views/global-partial.htm

  2. Use the {% include %} tag to include it in your theme

{% include 'acme.demo::global-partial' %}

This is the same as calling View::make in PHP

$contents = View::make('acme.demo::global-partial');
1 Like

…and pushing data to the view via twig also works:

{% include "my.plugin::test" with {'test': 'hi'} %}

This is a view test: 
{{ test }}

Didnt see this in the first place.

Thanks a lot ^^

1 Like