Changes between Version 28 and Version 29 of Usage/TemplatingDocumentation
- Timestamp:
- 07/09/12 17:36:47 (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Usage/TemplatingDocumentation
v28 v29 5 5 CMT utilizes Django's Templating engine to process templates. 6 6 7 For a complete description of the D Jango templating engine, please visit the DJango website here:7 For a complete description of the Django templating engine, please visit the DJango website here: 8 8 * [https://docs.djangoproject.com/en/dev/topics/templates/ The Django template language] 9 9 … … 23 23 == arpanize == 24 24 25 Converts a IP (range) to reversed DNS style arpanotation25 Converts an IP (range) to reversed DNS style ARPA notation 26 26 27 27 '''Usage''': … … 40 40 == base_net == 41 41 42 Converts a IP (range) to it's first 3 octects42 Converts an IP (range) to it's first 3 octets 43 43 44 44 '''Usage''': … … 57 57 == ip_last_digit == 58 58 59 Converts a IP (range) to it's last octect59 Converts an IP (range) to it's last octet 60 60 61 61 '''Usage''': … … 79 79 == assign == 80 80 81 Variable assignment within template 81 Concatenates any combination of (space separated) variable's and strings and assigns it to a new variable. 82 82 83 83 '''Usage''': … … 104 104 {{{ 105 105 {% getbasenets 'MY ADMIN' as network_basenets %} 106 106 107 {% for bnet in network_basenets %} 107 108 {{ bnet }} … … 124 125 125 126 '''Example's''': 126 * 127 {{{ 128 {% use HardwareUnit with 'cluster__name=Gina' as gina_hosts %} 129 {% getracks 'Gina' as gina_racks %} 130 131 {% for r in gina_racks %} 132 {% assign filename = '/var/tmp/hosts.' r.label '.in' %} 133 134 {% store filename %} 135 {% noblanklines %} 136 137 # Hosts file containing all hosts from rack: {{ r.label }} 138 139 {% for h in gina_hosts %} 140 {% if h.rack.label == r.label %} 141 142 {{ h.label }} 143 144 {% endif %} 145 {% endfor %} 146 147 {% endnoblanklines %} 148 {% endstore %} 149 127 128 Let's assume the cluster with name "TINA" consists of 3 racks with the labels: r1, r5, r6 129 130 * 131 {{{ 132 {% getracks 'TINA' as tina_racks %} 133 134 {% for r in tina_racks %} 135 {{ r.label }} 150 136 {% endfor %} 151 137 }}} 152 138 139 '''Example output''': 140 * 141 {{{ 142 r1 143 r5 144 r6 145 }}} 146 153 147 == use == 154 148 155 Compilation function to defin ine Querysets for later use.149 Compilation function to define Querysets for later use. 156 150 157 151 '''Usage''': … … 198 192 == noblanklines == 199 193 200 Prevents any blanklines occur ing in the resulting output (file).194 Prevents any blanklines occurring in the resulting output (file). 201 195 202 196 '''Section start''':