Skip to content

Commit

Permalink
Add "class" parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
martignoni committed Apr 6, 2019
1 parent d12c1f0 commit 127ecb7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions layouts/shortcodes/cloakemail.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{/* Get address and protocol */}}
{{- $address := .Get "address" | default (.Get 0) -}}
{{- $protocol := .Get "protocol" | default "mailto" -}}
{{- $class := .Get "class" -}}
{{- $parts := split $address "@" -}}
{{- $user := (index $parts 0) -}}
{{- $domain := (index $parts 1) -}}
Expand All @@ -20,6 +21,9 @@
var address = "{{ range $index := seq (sub (len $user) 1) 0}}{{ substr $user $index 1}}{{ end }}".split('').reverse().join('') + "@" + "{{ range $index := seq (sub (len $domain) 1) 0}}{{ substr $domain $index 1}}{{ end }}".split('').reverse().join('');
link.href = {{ $protocol }} + ":" + address;
link.innerText = address;
{{ with $class }}
link.className = "{{ $class }}";
{{ end }}
scriptTag.parentElement.insertBefore(link, scriptTag.previousElementSibling);
scriptTag.parentElement.removeChild(scriptTag.previousElementSibling)
</script>

0 comments on commit 127ecb7

Please sign in to comment.