# General object to bind properties to

**URL:** <https://community.silverfin.com/t/general-object-to-bind-properties-to/951>\
**Category:** Templates\
**Tags:** variables, result, capture\
**Created:** [June 1, 2018, 7:00am UTC](https://community.silverfin.com/t/general-object-to-bind-properties-to/951 "2018-06-01T07:00:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bart\_Verhaeghe](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@Bart\_Verhaeghe](https://community.silverfin.com/u/Bart_Verhaeghe)\
**Post date:** [June 1, 2018, 7:00am UTC](https://community.silverfin.com/t/general-object-to-bind-properties-to/951/1 "2018-06-01T07:00:32Z")

</div>

Hi,

It would be really great if there were an object to which one can ‘bind’ general methods and properties to (cfr. the ‘application’ object in Excel VBA).

That way, general functions that can be applied anywhere (such as ‘find the last occurence of a given substring in a string’) only have to be defined once and can be applied to an input that is not linked to either the period or the company object.

I find myself having to repeat some code over and over again (and - as a good friend-programmer once said - the ideal programmer is essentially a very lazy person who doesn’t like to repeat himself … 🙂

Or is there another way to solve this problem?

Thanks!

---

<div class="post-metadata">

**Author:** ![sven](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/sven/32/1495_2.png) [@sven](https://community.silverfin.com/u/sven)\
**Post date:** [June 1, 2018, 7:03am UTC](https://community.silverfin.com/t/general-object-to-bind-properties-to/951/2 "2018-06-01T07:03:41Z")

</div>

I feel you @Bart_Verhaeghe

Could you give examples of codes you have to repeat? Because if we think it can be generic and has benefits for other template builders, feel free to ask.

---

<div class="post-metadata">

**Author:** ![Bart\_Verhaeghe](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@Bart\_Verhaeghe](https://community.silverfin.com/u/Bart_Verhaeghe)\
**Post date:** [June 1, 2018, 7:10am UTC](https://community.silverfin.com/t/general-object-to-bind-properties-to/951/3 "2018-06-01T07:10:19Z")

</div>

Hi Sven and welcome to our daily talk ;-),

The sequence mentioned below takes a (structured) string in the form of A, B, C and ‘reforms’ it to A, B en C. Not mission critical in any way, but really handy to make an output more readable and ‘human’. So the input parameter (str\_VGD\_Vennootschappen\_Namen) is not bound to a company or a period object.

```auto
{% comment %}haal de namen van alle vennootschappen uit de parameters{% endcomment %}
  {% assign str_VGD_Vennootschappen_Namen = period.reconciliations.Parameters.results.VGD_Vennootschappen_Namen | strip %}
  {% assign arr_VGD_Vennootschappen_Namen = str_VGD_Vennootschappen_Namen | split: '|' %}
  {% assign int_XthCommaToReplace = arr_VGD_Vennootschappen_Namen.size | minus: 1 %}

{% comment %}vervang de '|' door ', ' (behalve de laatste door ' en '{% endcomment %}
{% for vennootschap in arr_VGD_Vennootschappen_Namen %}
  {% assign counter = counter | plus:1 %}
  {% if counter == int_XthCommaToReplace %}
    {% assign str_Vennootschappen_Correct = str_Vennootschappen_Correct | append: vennootschap | append: ' en ' %}
  {% else %}
    {% assign str_Vennootschappen_Correct = str_Vennootschappen_Correct | append: vennootschap | append: ', ' %}
  {% endif %}
{% endfor %}

{% assign str_Vennootschappen_Correct_Length = str_Vennootschappen_Correct.size | minus: 2 %}
{% assign str_Vennootschappen_Correct = str_Vennootschappen_Correct | slice: 0, str_Vennootschappen_Correct_Length %}

{{str_Vennootschappen_Correct}}

```

---

<div class="post-metadata">

**Author:** ![sven](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/sven/32/1495_2.png) [@sven](https://community.silverfin.com/u/sven)\
**Post date:** [June 1, 2018, 7:15am UTC](https://community.silverfin.com/t/general-object-to-bind-properties-to/951/4 "2018-06-01T07:15:52Z")

</div>

Hmmm okay, but once this code is made in one template, you can use it everywhere. So I don’t see how your code gets repeated? @Bart_Verhaeghe

Above code is not repeated in other templates, right? It’s only made in 1 template, I assume?

---

<div class="post-metadata">

**Author:** ![Bart\_Verhaeghe](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@Bart\_Verhaeghe](https://community.silverfin.com/u/Bart_Verhaeghe)\
**Post date:** [June 1, 2018, 8:14am UTC](https://community.silverfin.com/t/general-object-to-bind-properties-to/951/5 "2018-06-01T08:14:45Z")

</div>

Yes it is … I use this in three templates now.

How can I define this in one template and use it in another then?

Thanks for the great help! Think we’re on to something here …

---

<div class="post-metadata">

**Author:** ![sven](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/sven/32/1495_2.png) [@sven](https://community.silverfin.com/u/sven)\
**Post date:** [June 1, 2018, 8:19am UTC](https://community.silverfin.com/t/general-object-to-bind-properties-to/951/6 "2018-06-01T08:19:56Z")

</div>

You can capture that whole code, and take it into a result-tag. Or even better: the outcome of that code can be taken into a result-tag @Bart_Verhaeghe  
That way you can use it anywhere else

Why don’t you generate all needed code in that one template with the handle “Parameters”? Think that’s why you made it, no, looking at the name of that handle?
