Skip to content

Commit b1e818d

Browse files
authored
fix: allow specifying extra class name for blockquotes and tables (#245)
1 parent c27eea4 commit b1e818d

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

layouts/_default/_markup/render-blockquote-regular.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@
99
{{- $borderClass = printf "%s border-%d" $borderClass . }}
1010
{{- end }}
1111
{{- end }}
12-
{{- if .Attributes }}
12+
{{- $class := slice "blockquote" }}
13+
{{- with .Attributes.class }}
14+
{{- $class = $class | append . }}
15+
{{- end }}
16+
{{- if or (isset .Attributes "align") (isset .Attributes "caption") }}
1317
<figure
1418
class="{{ $borderClass }}{{ with .Attributes.align }} text-{{ . }}{{ end }}">
15-
<blockquote class="blockquote mb-0">
19+
<blockquote class="{{ delimit $class ` ` }} mb-0">
1620
{{ .Text }}
1721
</blockquote>
1822
{{- with .Attributes.caption }}
@@ -25,7 +29,7 @@
2529
{{- end }}
2630
</figure>
2731
{{- else }}
28-
<blockquote class="blockquote {{ $borderClass }}">
32+
<blockquote class="{{ delimit $class ` ` }} {{ $borderClass }}">
2933
{{ .Text }}
3034
</blockquote>
3135
{{- end }}

layouts/_default/_markup/render-table.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,14 @@
4646
"left" "text-start"
4747
"right" "text-end"
4848
}}
49+
{{- with .Attributes.class }}
50+
{{- $class = printf "%s %s" $class . }}
51+
{{- end }}
4952
<div class="table-responsive">
5053
<table class="{{ $class }}"
5154
{{- range $k, $v := .Attributes }}
52-
{{- if hasPrefix $k "_" }}
55+
{{- if or (hasPrefix $k "_") (eq $k "class") }}
5356
{{- continue }}
54-
{{- else if eq $k "class" }}
55-
{{- $class = printf "%s %s" $class $v }}
5657
{{- else if $v }}
5758
{{- printf " %s=%q" $k $v | safeHTMLAttr }}
5859
{{- end }}

0 commit comments

Comments
 (0)