"Partial" Parameters

I want to make dynamic items, like a table, which I can configure across pages, but there’s no way to include variables across partials that can also be seen by Wappler (at least not without fancy coding I’m sure). For example, the parent page could include my control/partial file (.ejs in my case: such as button.ejs), and the control/partial would expose some required input/argument properties to satisfy requirements for the control/partial. This would require supporting a way to generated dynamic IDs for the controls. I guess this would be a “template partial”? For example, not all buttons on my page should have id='button'. A “Template Partial” should contain an ID for the root of the partial, which I can specify in the template. For example:

Parent page: 
    App
       Dynamic Modal: addSomething
         Template Partial: Button (id = save1, caption = Save)
         Template Partial: Button (id = cancel1, caption = Cancel)
       Dynamic Modal: addSomethingElse
         Template Partial: Button (id = save2, caption = Save)
         Template Partial: Button (id = cancel2, caption = Cancel)

Button.ejs

<button id="btn{{id}}">{{Captaion}}</button>

You can already define parameters to the partials.

Just open the partial and define a template data, those are the possible parameters:

Then you can populate it within the partial, just select a place in code and click:

and select the parameter to use:

This will add a parameter binding in the code:
image

Then on a different page, when you use the partial, you can pass the right data:

1 Like

Nice! Going to try that now, thanks. :slight_smile:

@George Is there a way to select the partial page’s meta variables in expressions? I wanted to do this:

But it’s not there. I hate doing this:

Because the step editor does not seem to work properly with that (notice how it shows the ID names incorrectly, because it strips out the <%%>), and thus it may be better to support allowing people to select it from the popup (which yes, I assume is a client side value at that point).

For now, my workaround is to try using this with the expressions:
<dmx-value id="tableName" dmx-bind:value="<%=_('tableName',locals)%>"></dmx-value>
Would just be nice if it was better supported - perhaps allow setting values to the template values?

Another idea might be to support template types. For example, I may say I’m expecting a server action to return certain values, which I expect to be fulfilled by the parent page. This type would be added as a typed object somewhere, and a reference linking the type to an object on the parent would help Wappler translate which object to use in the parent with the template partial. Why? Because It’s better than doing this:
image
I’d rather do something like this:
image
Where that template object might also have template properties I can select as well.

This is not going to work as I was thinking. I forgot the server side render is not within the client side context when the table renders. This renders one time:

image

There’s no way for me to pass a row ID, or any data for that row. It would be fine if I were dong mostly server side template rendering, but I’m doing it dynamically client side, so partials are not the best answer here (PWA project).