45 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
{{/*
 | 
						|
  socials/Get
 | 
						|
  Returns the list of services registered by the user complemented by the built-in service default data if found.
 | 
						|
 | 
						|
  @author @regisphilibert
 | 
						|
 | 
						|
  @context Any (.)
 | 
						|
 | 
						|
  @access public
 | 
						|
 | 
						|
  @returns Slice of Maps
 | 
						|
    - String (.name)
 | 
						|
      String (.url)
 | 
						|
      String (.label)
 | 
						|
      String (.color)?
 | 
						|
      Bool (.share)?
 | 
						|
  @uses
 | 
						|
     - partial
 | 
						|
 | 
						|
  @example - Go Template
 | 
						|
    {{ with partialCached "socials/Get" context context }}
 | 
						|
      {{ something = . }}
 | 
						|
    {{ end }}
 | 
						|
*/}}
 | 
						|
{{ $socials := slice }}
 | 
						|
{{ with partial "func/socials/GetRegisteredServices" "GetRegisteredServices" }}
 | 
						|
  {{ range . }}
 | 
						|
    {{ $service := . }}
 | 
						|
    {{/* We fetch the default data and add it to service map if found */}}
 | 
						|
    {{ with partialCached "func/socials/GetServiceData" .name .name }}
 | 
						|
      {{ $service = merge . $service }}
 | 
						|
    {{ end }}
 | 
						|
    {{/* We fetch the icon and add it to service map fi found */}}
 | 
						|
    {{ with partialCached "func/socials/GetServiceIcon" .name .name }}
 | 
						|
      {{ $service = $service | merge (dict "icon" . ) }}
 | 
						|
    {{ end }}
 | 
						|
    {{/* In case no label is provided (on a non-built-in service) we add the .name as label to the service map */}}
 | 
						|
    {{ with .label }}{{ else }}
 | 
						|
      {{ $service = $service | merge (dict "label" $service.name ) }}
 | 
						|
    {{ end }}
 | 
						|
    {{ $socials = $socials | append $service }}
 | 
						|
  {{ end }}
 | 
						|
{{ end }}
 | 
						|
 | 
						|
{{ return $socials }} |