247 |
URL
248 |
249 |
250 |
251 |
252 |
URL helpers are
253 | node.js url utilities for URL resolution and parsing. As with node.js:
254 |
255 |
256 |
257 |
{{urlParse}}
258 |
259 |
260 |
Take a URL string, and return an object.
261 |
262 |
263 |
264 |
Params
265 |
266 |
267 |
url
268 |
269 |
270 |
Type: String
271 | Default: undefined
272 |
273 |
274 |
275 |
The URL to parse.
276 |
277 |
278 |
279 |
280 |
281 |
Type: String
282 | Default: json (options: yaml or json)
283 |
284 |
285 |
Template:
286 |
287 |
{{urlParse "http://example.com/one"}}
288 |
Renders to:
289 |
{
290 | "protocol ": "http:" ,
291 | "slashes ": true ,
292 | "auth ": null ,
293 | "host ": "example.com" ,
294 | "port ": null ,
295 | "hostname ": "example.com" ,
296 | "hash ": null ,
297 | "search ": null ,
298 | "query ": null ,
299 | "pathname ": "/one" ,
300 | "path ": "/one" ,
301 | "href ": "http://example.com/one"
302 | }
303 |
Or with yaml as the second param:
304 |
{{urlParse "http://foo.com/bar/baz?key=value" "yaml"}}
305 |
Renders to:
306 |
protocol: "http:"
307 | slashes: true
308 | auth: null
309 | host: "foo.com"
310 | port: null
311 | hostname: "foo.com"
312 | hash: null
313 | search: "?key=value"
314 | query: "key=value"
315 | pathname: "/bar/baz"
316 | path: "/bar/baz?key=value"
317 | href: "http://foo.com/bar/baz?key=value"
318 | parse:
319 | format:
320 | resolve:
321 | resolveObject:
322 | parseHost:
323 |
{{urlResolve}}
324 |
Take a base URL, and a href URL, and resolve them as a browser would for an anchor tag.
325 |
326 |
327 |
Template:
328 |
{{urlResolve url href}}
329 |
Example:
330 |
<a href="{{urlResolve "http://example.com/one" "/two"}}"></a>
331 |
Renders to:
332 |
<a href="http://example.com/two"></a>
333 |
334 |
335 | See the template for this page →
336 |
337 |
338 |
345 |
346 |
347 |
Find an error?
348 | Let us know →
349 |
350 |
351 |