pass value into snippet possible or do I have create multiple snippets?

  • 1
  • Question
  • Updated 4 years ago
  • Answered
I'd like to call a function from several different components/models. I'm asking this as rhetorical question.
I'm assuming I need to create a snippet for each specific model/component in order to be able to call the main function with the id of the model I'd like to use. In other words, each snippet will only be calling my main function with the "modelid" parameter passed in.

Do I have this right?
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,674 Points 20k badge 2x thumb

Posted 4 years ago

  • 1
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,470 Points 10k badge 2x thumb
Yes, this is a perfectly valid way to organize your code.
Photo of Menachem Shanowitz

Menachem Shanowitz

  • 1,074 Points 1k badge 2x thumb
I am not necessarily suggesting to do this, but If I am not mistaken, the model that is 'calling' the snippet would already be included in the arguments[0] parameter, so one snippet can be sufficient for all the models.
(Edited)