Im wondering, where to put commonly used parameters and computed values into. These parts of my application should be accessable from different lacations. They should get called from the frontend (templates) via helpers or something as well get used within components (the JS-Part).
As an simple example (which may not be necessarily a good example for that requirement), ive got the following use case: I want to be able, to get a specific css class name in my templates, regardless to the surrounding tag or place (div, h1, … ) from where im calling that mechanism. Also I want to pass some arguments (lets say a number as an id) to this function.
Routes-Template
...
<h1 class="{{getSpecialDesignCSSClassName arg1=4}}"> Header </h1>
...
or one more example
...
<div class="{{getSpecialDesignCSSClassName arg1=model.categoryType}}">
Header
</div>
...
That should result in something like that
...
<h1 class="greenTheme"> Header </h1>
...
or
...
<div class="purpleTheme">
Header
</div>
...
The function should look something like that:
switch(arg1) {
case 4:
return "greenTheme"
...
default:
return "purpleTheme"
}
As I mentioned before: This might not a proper usecase for a requirement I described at the beginning. But this is here just for making clear what Iam going to realise or more precisely I want to know how to solve in general (when common logic should be reusable, generic with parameters and easely accessable).
So what would you guys do?