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

  • 1
  • Question
  • Updated 5 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 Pat Vachon

Pat Vachon, Champion

  • 44,426 Points 20k badge 2x thumb

Posted 5 years ago

  • 1
Photo of Ben Hubbard

Ben Hubbard, Employee

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

Menachem Shanowitz

  • 1,094 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.