TEXT_RENDER (text)
Processes provided text to replace special placeholders for their corresponding values.
It also allows to use Twig syntax to provide programmable capabilities (loops, conditions...)
Input Parameters
Parameter | Type | Description |
---|---|---|
text | string | Text to be rendered. To insert double quotes in the text, use scape sequence: \" |
Output
Parameter | Type | Description |
---|---|---|
return value | string | plain text with the placeholders replaced by their corresponding values. |
Allowed placeholders
Placeholder | Description |
---|---|
{{OBJECT CODE}} | Substitutes the placeholder for the value of the corresponding CODE |
{{TRANS['langcode1':'text', 'langcode2':'text'...]}} | Substitutes the placeholder for the string matching the active language. It is possible to provide the text in several languages, and the system will select the appropriate text depending on the active language If none of the texts provided matches the active language, then an automatic translation will be performed |
Execution
on form_get_summary()
Examples
TEXT_RENDER("Result of the spirometry: {{FORM.DATACODE.FEV1}}")
returns: Result of the spirometry: 16
TEXT_RENDER("{{TRANS['en':'Result of the spirometry';'es':'Resultado de la espirometría']}}: {{FORM.DATACODE.FEV1}}")
returns:
- if active language is english: Result of the spirometry: 16
- if active language is spanish: Resultado de la espirometría: 16
- Otherwise: the text will be translated automatically to the active language
The following example shows how TEXT_RENDER can also be used to render a piece of HTML code to be inserted in a web page and presented in a browser inserted. This example also shows has Twig syntax can be used:
TEXT_RENDER("<table border=\"0\" style=\"background-color:white;border-collapse:collapse;border:0px solid black;color:black;width:100%\" cellpadding=\"9\" cellspacing=\"9\"><thead><tr><th ></th><th><b>FVC</b></th><th><b>FEV1</b></th><th><b>FEV1/FVC</b></th><th><b>PEF</b></th><th><b>FEF25-75</b></th></tr></thead><tbody>{% for key,value in ADMISSION.DATA.SPIRO.PBD.FEV1 %}<tr><td><b>{{loop.index}}</b></td><td>{{ ADMISSION.DATA.SPIRO.PBD.FVC[loop.index0] }}</td><td>{{ ADMISSION.DATA.SPIRO.PBD.FEV1[loop.index0] }}</td><td>{{ ADMISSION.DATA.SPIRO.PBD.FEV1-FVC[loop.index0] }}</td><td>{{ ADMISSION.DATA.SPIRO.PBD.PEF[loop.index0] }}</td><td>{{ ADMISSION.DATA.SPIRO.PBD.FEF2575[loop.index0] }}</td></tr>{% endfor %}</tbody></table>")
This will show something like: