17 lines
		
	
	
		
			624 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			17 lines
		
	
	
		
			624 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
| {{- $method := .Get "method" | default "get" -}}
 | |
| {{- $url := .Get 0 | default (.Get "url") -}}
 | |
| 
 | |
| {{- if not $url -}}
 | |
|     {{- errorf "layouts/shortcodes/paige/request.html: no url" -}}
 | |
| {{- end -}}
 | |
| 
 | |
| {{- with try (resources.GetRemote $url (dict "method" $method)) -}}
 | |
|     {{- with .Err -}}
 | |
|         {{- errorf "layouts/shortcodes/paige/request.html: cannot request remote resource %q: %v" $url . -}}
 | |
|     {{- else with .Value -}}
 | |
|         {{- strings.TrimRight "\f\n\r\t\v " .Content -}}
 | |
|     {{- else -}}
 | |
|         {{- errorf "layouts/shortcodes/paige/request.html: remote resource %q not found" $url -}}
 | |
|     {{- end -}}
 | |
| {{- end -}}
 |