example.html 1.0 KB

1234567891011121314151617181920212223242526
  1. {{- /*
  2. Usage: `example [args]`
  3. `args` are optional and can be one of the following:
  4. id: the `div`'s id - default: ""
  5. class: any extra class(es) to be added to the `div` - default ""
  6. show_preview: if the preview should be output in the HTML - default: `true`
  7. show_markup: if the markup should be output in the HTML - default: `true`
  8. */ -}}
  9. {{- $lang := .Get "lang" | default "html" -}}
  10. {{- $show_preview := .Get "show_preview" | default true -}}
  11. {{- $show_markup := .Get "show_markup" | default true -}}
  12. {{- $input := .Inner -}}
  13. {{- if eq $show_preview true -}}
  14. <div{{ with .Get "id" }} id="{{ . }}"{{ end }} class="bd-example{{ with .Get "class" }} {{ . }}{{ end }}">
  15. {{- $input -}}
  16. </div>
  17. {{- end -}}
  18. {{- if eq $show_markup true -}}
  19. {{- $content := replaceRE `<svg class="bd\-placeholder\-img(?:\-lg)?(?: *?bd\-placeholder\-img\-lg)? ?(.*?)".*?<\/svg>\n` `<img src="..." class="$1" alt="...">` $input -}}
  20. {{- $content = replaceRE ` (class=" *?")` "" $content -}}
  21. {{- highlight (trim $content "\n") $lang "" -}}
  22. {{- end -}}