| 1 |
PVTPL Module |
| 2 |
|
| 3 |
Daniel-Constantin Mierla |
| 4 |
|
| 5 |
asipto.com |
| 6 |
<[email protected]> |
| 7 |
|
| 8 |
Edited by |
| 9 |
|
| 10 |
Daniel-Constantin Mierla |
| 11 |
|
| 12 |
<[email protected]> |
| 13 |
|
| 14 |
Copyright © 2024 http://www.asipto.com |
| 15 |
__________________________________________________________________ |
| 16 |
|
| 17 |
Table of Contents |
| 18 |
|
| 19 |
1. Admin Guide |
| 20 |
|
| 21 |
1. Overview |
| 22 |
2. Dependencies |
| 23 |
|
| 24 |
2.1. Kamailio Modules |
| 25 |
2.2. External Libraries or Applications |
| 26 |
|
| 27 |
3. Parameters |
| 28 |
|
| 29 |
3.1. tpl (str) |
| 30 |
|
| 31 |
4. Functions |
| 32 |
|
| 33 |
4.1. pvtpl_render(tplname, res) |
| 34 |
|
| 35 |
5. Template File |
| 36 |
|
| 37 |
List of Examples |
| 38 |
|
| 39 |
1.1. Set tpl parameter |
| 40 |
1.2. pvtpl_render usage |
| 41 |
1.3. Template file |
| 42 |
|
| 43 |
Chapter 1. Admin Guide |
| 44 |
|
| 45 |
Table of Contents |
| 46 |
|
| 47 |
1. Overview |
| 48 |
2. Dependencies |
| 49 |
|
| 50 |
2.1. Kamailio Modules |
| 51 |
2.2. External Libraries or Applications |
| 52 |
|
| 53 |
3. Parameters |
| 54 |
|
| 55 |
3.1. tpl (str) |
| 56 |
|
| 57 |
4. Functions |
| 58 |
|
| 59 |
4.1. pvtpl_render(tplname, res) |
| 60 |
|
| 61 |
5. Template File |
| 62 |
|
| 63 |
1. Overview |
| 64 |
|
| 65 |
The module reads content of files at startup and can evaluate the |
| 66 |
variables inside during runtime. |
| 67 |
|
| 68 |
2. Dependencies |
| 69 |
|
| 70 |
2.1. Kamailio Modules |
| 71 |
2.2. External Libraries or Applications |
| 72 |
|
| 73 |
2.1. Kamailio Modules |
| 74 |
|
| 75 |
The following modules must be loaded before this module: |
| 76 |
* None. |
| 77 |
|
| 78 |
2.2. External Libraries or Applications |
| 79 |
|
| 80 |
The following libraries or applications must be installed before |
| 81 |
running Kamailio with this module loaded: |
| 82 |
* None. |
| 83 |
|
| 84 |
3. Parameters |
| 85 |
|
| 86 |
3.1. tpl (str) |
| 87 |
|
| 88 |
3.1. tpl (str) |
| 89 |
|
| 90 |
The definition of a template file: |
| 91 |
* "name=_string_;fpath=_number_;bsize=_number_" |
| 92 |
|
| 93 |
The parameter can be set multiple times to get more templates in same |
| 94 |
configuration file. |
| 95 |
* name - name of the template. |
| 96 |
* fpath - path to the template file. |
| 97 |
* bsize - buffer size to evaluate the template (default: 1024). |
| 98 |
|
| 99 |
Default value is NULL. |
| 100 |
|
| 101 |
Example 1.1. Set tpl parameter |
| 102 |
... |
| 103 |
modparam("pvtpl", "tpl", "name=tpl1;fpath=/etc/kamailio/tpl1.pvtpl;bsize=512;") |
| 104 |
modparam("pvtpl", "tpl", "name=tpl2;fpath=/etc/kamailio/tpl2.pvtpl;bsize=256;") |
| 105 |
... |
| 106 |
|
| 107 |
4. Functions |
| 108 |
|
| 109 |
4.1. pvtpl_render(tplname, res) |
| 110 |
|
| 111 |
4.1. pvtpl_render(tplname, res) |
| 112 |
|
| 113 |
Render the template 'tplname' using config variables, setting the |
| 114 |
result in the variable specified by 'res'. |
| 115 |
|
| 116 |
This function can be used from ANY_ROUTE. |
| 117 |
|
| 118 |
Example 1.2. pvtpl_render usage |
| 119 |
... |
| 120 |
pvtpl_render("t1", "$var(out)"); |
| 121 |
... |
| 122 |
|
| 123 |
5. Template File |
| 124 |
|
| 125 |
The template file can contain text and config variables that are |
| 126 |
evaluate when running pvtpl_render() functions. |
| 127 |
|
| 128 |
The templates files are loaded at startup and prepared for runtime. It |
| 129 |
is no option to reload the template files. |
| 130 |
|
| 131 |
Example 1.3. Template file |
| 132 |
... |
| 133 |
{ |
| 134 |
"from": "$fu", |
| 135 |
"to": "$tu", |
| 136 |
"x" : $var(x) |
| 137 |
} |
| 138 |
... |