.. _macro-evaluate-function:

Macro evaluate function
------------------------

.. index:: Macro function;fn.evaluate

* *fn.evaluate*: Evaluate the string using the macro
  interpreter. 
  
  The string can be a macro and can 
  also contain macro names to be evaluated.       

  The purpose of the function is so that we can save 
  data as a macro and then evaluate it when we 
  read it again.
  
  For example, we may store default values in a data
  model (e.g. ``SiteDefaultsDoc``) that may also refer to 
  existing macros. An attribute of the model - 
  with name: ``defaulthppt`` can for example 
  have the value (The macro evaluates to a site name):
  
  ::
  
     Site-{{macro.SITENAME}}

      
    
  Then, a workflow Configuration Template at a Site 
  can be a set to a value that references the model and
  that uses ``fn.evaluate``:

  
  :: 
   
     "defaulthppt": "{{ fn.evaluate data.SiteDefaultsDoc.defaulthppt }}",
  
  
  Not:


  :: 
   
     "defaulthppt": "Site-{{macro.SITENAME}}",
    


The tables below provide further examples.  
  
Where ``self.x`` specifies an attribute of a model,
with the value:

::

    {# data.Countries.iso_country_code | country_name:'South Africa' #} 


.. tabularcolumns:: |p{11cm}|p{4cm}|

+----------------------------------------------------+-----------------------------+
|  Example                                           | Output                      |
+====================================================+=============================+
| Then:                                              |                             |
| ::                                                 | ::                          |
|                                                    |                             |
|    {# fn.evaluate self.x #}                        |    ['ZAF']                  |
|                                                    |                             |
+----------------------------------------------------+-----------------------------+


Where ``MACRO1`` is:

::

    {{ data.Countries.emergency_access_prefix | iso_country_code:FRA }}


Where self.x is: 


::

    {# data.Countries.iso_country_code | emergency_access_prefix:macro.MACRO1 #} 



.. tabularcolumns:: |p{11cm}|p{4cm}|

+-----------------------------+--------------------------------+
|  Example                    | Output                         |
+=============================+================================+
| Then:                       | Codes with same prefix as FRA: |
|                             |                                |
| ::                          | ::                             |
|                             |                                |
|    {# fn.evaluate self.x #} |    ['DNK','HKG',               |
|                             |     'FRA','DEU',               |
|                             |     'IND','ITA',               |
|                             |     'NLD','NZL',               |
|                             |     'SAU','ESP',               |
|                             |     'SWE','ZAF',               |
|                             |     'CHE','TUR']               |
|                             |                                |
+-----------------------------+--------------------------------+







.. |VOSS Automate| replace:: VOSS Automate
.. |Unified CM| replace:: Unified CM
