Inject Mithril Components by ReFlar
Inject Mithril components into your pages using native HTML. Requested by @fardogah.
Note: This extension was made specifically to inject DiscussionList
, and had some modifications made to the component so it would work properly. However, it should work with all components (except modals) that don't require Model or Component instances to be passed... among other things.
Usage
This extension adds a custom HTML tag called flarum-component
.
The component must be exposed through the Flarum compat API to be injected (most Flarum core components are)
Use the data-component
attribute to set the component to use. Add more attributes to pass as props to the component.
Add :
before the parameter name to parse it as JSON and/or evaluate it using eval
("true"
-> true
)
Using FriendsOfFlarum Pages, injecting the discussion list with 1 discussion from the tag hidden
:
<flarum-component
data-component="components/DiscussionList"
:params="{filter:{q:'tag:hidden'},page:{limit:1}}">
</flarum-component>
This is the equivalent of:
import DiscussionList from 'flarum/components/DiscussionList';
DiscussionList.component({
params: {
filter: {
q: 'tag:hidden'
},
page: {
limit: 1
}
}
});
Installation
Use Bazaar or install manually with composer:
composer require reflar/inject-mithril-components
Updating
composer update reflar/inject-mithril-components
Links