| | 199 | ===== name_template details ===== |
| | 200 | |
| | 201 | **Name templates can be used to define custom formatting for OSM primitives or GPX waypoints** (for example in the Relations or the Selection). |
| | 202 | |
| | 203 | {{{ |
| | 204 | #!xml |
| | 205 | <?xml version="1.0" encoding="UTF-8"?> |
| | 206 | <presets> |
| | 207 | <item name="Public transportation" type="relation" |
| | 208 | name_template="Bus({operator} {ref} ?{'{from} - {via} - {to}' | '{from} - {to}' | '{from}' | '{to}'})" |
| | 209 | name_template_filter="type=route route=bus"> |
| | 210 | </item> |
| | 211 | </presets> |
| | 212 | }}} |
| | 213 | |
| | 214 | '''Samples''' |
| | 215 | ||= Template =||= Tags =||= Result =|| |
| | 216 | || `House number {addr:housenumber}` || `addr:housenumber=10` || House number 10 |
| | 217 | || `?{ 'House number {addr:housenumber} at {addr:street}' | 'House number {addr:housenumber}' }` || `addr:housenumber=10` || House number 10 |
| | 218 | || || `addr:housenumber=10 addr:street=Abbey road` || House number 10 at Abbey road |
| | 219 | || `?{ admin_level = 2 'NUTS 1' | admin_level = 4 'NUTS 2' | admin_level = 6 'NUTS 3' | 'Admin level {admin_level}'}` || `admin_level=4` || NUTS 2 |
| | 220 | || || `admin_level=5` || Admin level 5 |
| | 221 | || `{admin_level} - {name} !{parent() type=boundary '?{'(part of {admin_level} - {name})' | ''}'}` || `admin_level=6 name=Vysocina`, member of relation `admin_level=4 name=Jihovychod` || 6 - Vysocina (part of Jihovychod) |
| | 222 | || || `admin_level=2 name=Czech republic` (no parents) || 2 - Czech republic |
| | 223 | |
| | 224 | ====== Syntax ====== |
| | 225 | * `{var}` - use value of variable var |
| | 226 | * `?{condition1 'value1' | condition2 'value2 | 'value3'}` - use value1 if condition1 is satisfied, value3 is no condition is satisfied. Condition can be either explicit - the same expression as in search or filters is used - or implicit; the value is used when all variables used inside exist |
| | 227 | * `!{search_expression 'template'}` - search_expression is evaluated and first matching primitive is used as context for template. Useful for example to get tags of parent relation. |
| | 228 | |
| | 229 | ====== Available values ====== |
| | 230 | For formatting of OSM primitives , the value of any tag can be used. You can use `{special:everything}` to see what values are available for your gpx waypoints. |
| | 231 | |
| | 232 | Some additional variables are available via the special prefix: |
| | 233 | - `{special:everything}` prints all available values, available for formatting of both primitives and waypoints. |
| | 234 | - `{special:id}` prints the ID of an osm primitive |
| | 235 | - `{special:localName}` prints the localized name, that is the value of name:lang for your language if it is available or the value of the name tag if it doesn't. |
| | 236 | |