Skip to content

Commit

Permalink
Add 'show_edit_btn' param for example shortcode
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-deramond committed Mar 31, 2022
1 parent bef4f3b commit 89cdd8a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion site/content/docs/5.1/components/alerts.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Alerts are available for any length of text, as well as an optional close button

Click the button below to show an alert (hidden with inline styles to start), then dismiss (and destroy) it with the built-in close button.

{{< example >}}
{{< example show_edit_btn="false" >}}
<div id="liveAlertPlaceholder"></div>
<button type="button" class="btn btn-primary" id="liveAlertBtn">Show live alert</button>
{{< /example >}}
Expand Down
4 changes: 4 additions & 0 deletions site/layouts/shortcodes/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
* class: any extra class(es) to be added to the `div` - default: ""
* show_preview: if the preview should be output in the HTML - default: `true`
* show_markup: if the markup should be output in the HTML - default: `true`
* show_edit_btn: if the edit button should be displayed - default: `true`
*/ -}}

{{- $id := .Get "id" -}}
{{- $class := .Get "class" -}}
{{- $lang := .Get "lang" | default "html" -}}
{{- $show_preview := .Get "show_preview" | default true -}}
{{- $show_markup := .Get "show_markup" | default true -}}
{{- $show_edit_btn := .Get "show_edit_btn" | default true -}}
{{- $input := .Inner -}}

{{- if eq $show_preview true -}}
Expand All @@ -22,9 +24,11 @@
{{- end -}}

{{- if eq $show_markup true -}}
{{- if eq $show_edit_btn true -}}
<div class="bd-edit">
<button type="button" class="btn-edit text-nowrap" title="Try it on StackBlitz">Try it</button>
</div>
{{- end -}}
{{- $content := replaceRE `<svg class="bd-placeholder-img(?:-lg)?(?: *?bd-placeholder-img-lg)? ?(.*?)".*?<\/svg>\n` `<img src="..." class="$1" alt="...">` $input -}}
{{- $content = replaceRE ` (class=" *?")` "" $content -}}
{{- highlight (trim $content "\n") $lang "" -}}
Expand Down

0 comments on commit 89cdd8a

Please sign in to comment.