Placeholders in snippets - Mendix Forum

Placeholders in snippets

90

It would be nice to define placeholders in snippets. So there is room inside the snippet for the caller of the snippet to do extra stuff. Sometimes I create almost duplicate pages/snippets only because there needs to be a button somewhere between the rest of the snippet.

As an extra it would be nice, inside that placeholder, to be able to use the context of the caller of the snippet as a parameter for a microflow.

asked
10 answers

do it!

Created

Pluggable snippets :D 

5 years ago....

Created

when nesting multiple snippets today the most underlying element needed an onclick action but only on a specific page, needed to rebuild out the entire snippet so now I have 2 versions of the same snippet with similar underlying elements.

Created

I coudn't agree more with placeholders in Snippets. I think it's one of the most important features Mendix could implement in order to become more modular. The lack of options here is one of the major reason you're forced to create technical debt by copy pasting things that shouldn't be duplicated. It will allow all kinds of excellent improvements:

  • Creating page titles, title bars and other layout elements that can be re-used and defined once. No more inconsitencies, or editng 100s of pages when you want to change some basic styling and/ or add some functionality. This component way of working is already the defacto method for almost every modern frontend library like React, Angular and Vue and for good reason.
  • Creating re-usable plug and play components. Think interactive master detail pages, a custom collapsable groupbox, a chat functionalitiy, a datagrid that has multiple versions all purely in Mendix. Basically creating re-usable “widgets” in pure Mendix by defining a snippet. 
  • Defining snippet components in a design system. This can be done in a company module that is used in all applications. Want to change somthing company wide? Just change the appropiate snippet once.
  • Really I could go on and on about this.

Offcourse I know about building blocks but everytime I use one I'm like there is some additional technical debt for you. 

Created

this sound a lot like the idea for “building blocks2”

where you have the placeholders like in layouts where you can add page specific elements.

also having the ability to update the building blocks in a central location.

I also think tools such as Figma do a great job of what you can or cant change in an “instance” of an asset.

Created

Also please allow islands inside of the placeholder. example, snippet has a placeholder. And that placeholder has an island where the original snippet can continue to add stuffs.

Created

yes this would be handy!

Created

Do something with this! 3 months ago, someone requested the same, it is still wanted so bad!

Created

By doing so, Snippets could almost turn into whole blocks of functionality and yes, please do that. 

We work with a lot of manual components and prefer to use list views with our own filters, instead of datagrids. A layout grid, a few containers and some classes that every time have to be copied. If we could just reuse the same snippet and use different input fields, then everything would be so much easier and our product must more consistent with our more effort. 

Created

Excellent idea, this would be very useful for certain projects!

Created