-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
48 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,11 @@ | ||
{{- $icons := dict | ||
"caution" "images/icons/alerts/stop.svg" | ||
"important" "images/icons/alerts/report.svg" | ||
"note" "images/icons/alerts/info.svg" | ||
"tip" "images/icons/alerts/light-bulb.svg" | ||
"warning" "images/icons/alerts/alert.svg" | ||
-}} | ||
|
||
{{- $Attrs := "" }} | ||
{{- $attrs := "" }} | ||
{{- range $key, $value := .Attributes }} | ||
{{- if $value }} | ||
{{- $Attrs = printf "%s %s=%q" $Attrs $key $value }} | ||
{{- end }} | ||
{{- $attrs = printf "%s %s=%q" $attrs $key $value }} | ||
{{- end }} | ||
{{- $Attrs = trim $Attrs " " }} | ||
{{- $attrs = trim $attrs " " }} | ||
|
||
{{- if eq .Type "alert" -}} | ||
{{- with .Attributes.class }} | ||
{{- $Attrs = trim (replace $Attrs . (printf "alert alert-%s %s" $.AlertType .)) " " }} | ||
{{- else }} | ||
{{- $Attrs = trim (printf "class=%q %s" (printf "alert alert-%s" $.AlertType) $Attrs) " " }} | ||
{{- end -}} | ||
<div {{ $Attrs | safeHTMLAttr }}> | ||
{{- $icon := index $icons .AlertType -}} | ||
<p class="alert-title"> | ||
{{- dict "Src" $icon | partial "plugin/icon.html" }} | ||
{{- or (T (printf "alert.%v" .AlertType)) (title .AlertType) -}} | ||
</p> | ||
{{- .Text | safeHTML -}} | ||
</div> | ||
{{- dict "Text" .Text "Type" .AlertType "Attributes" .Attributes | partial "plugin/alert.html" -}} | ||
{{- else -}} | ||
<blockquote {{- with $Attrs }} {{ . | safeHTMLAttr }}{{ end }}>{{ .Text | safeHTML }}</blockquote> | ||
<blockquote {{- with $attrs }} {{ . | safeHTMLAttr }}{{ end }}>{{ .Text | safeHTML }}</blockquote> | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{{- /* | ||
This partial is used to render an alert box. | ||
@param {String} .Type the type of the alert box | ||
@param {String} .Text the content of the alert box | ||
@param {Map} [.Attributes] the attributes of the alert box | ||
@example {{- dict "Text" .Text "Type" .AlertType "Attributes" .Attributes | partial "plugin/alert.html" -}} | ||
*/ -}} | ||
|
||
{{- $icons := dict | ||
"caution" "images/icons/alerts/stop.svg" | ||
"important" "images/icons/alerts/report.svg" | ||
"note" "images/icons/alerts/info.svg" | ||
"tip" "images/icons/alerts/light-bulb.svg" | ||
"warning" "images/icons/alerts/alert.svg" | ||
-}} | ||
|
||
{{- $attrs := "" }} | ||
{{- range $key, $value := .Attributes }} | ||
{{- $attrs = printf "%s %s=%q" $attrs $key $value }} | ||
{{- end }} | ||
|
||
{{- with .Attributes.class }} | ||
{{- $attrs = replace $attrs . (printf "alert alert-%s %s" $.Type .) }} | ||
{{- else }} | ||
{{- $attrs = printf "class=%q %s" (printf "alert alert-%s" $.Type) $attrs }} | ||
{{- end }} | ||
{{- $attrs = trim $attrs " " -}} | ||
|
||
<div {{ $attrs | safeHTMLAttr }}> | ||
{{- $icon := index $icons .Type -}} | ||
<p class="alert-title"> | ||
{{- dict "Src" $icon | partial "plugin/icon.html" }} | ||
{{- or (T (printf "alert.%v" .Type)) (title .Type) -}} | ||
</p> | ||
{{- .Text | safeHTML -}} | ||
</div> | ||
{{- /* EOF */ -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters