diff --git a/_includes/example.html b/_includes/example.html new file mode 100644 index 0000000000..24d12626b6 --- /dev/null +++ b/_includes/example.html @@ -0,0 +1,23 @@ +{%- comment -%} +Usage: {% include example.html content=markup %}, +where content is a capture with the HTML content +id - null (default) +class - "bd-example" (default) +optional: hide_preview - disabled (default) +optional: hide_markup - disabled (default) +{%- endcomment -%} + +{%- assign preview_id = include.id -%} +{%- assign preview_class = include.class -%} + +{%- if include.hide_preview == null -%} +
#{code}
tags to code blocks
- code = code.sub(/\n*/,'')
- code = code.sub(/\n*<\/pre>/,"
")
- code.strip
- end
-
- end
- end
-end
-
-Liquid::Template.register_tag('example', Jekyll::Tags::ExampleBlock)
diff --git a/docs/4.0/components/alerts.md b/docs/4.0/components/alerts.md
index 54739990eb..6c6cb99366 100644
--- a/docs/4.0/components/alerts.md
+++ b/docs/4.0/components/alerts.md
@@ -10,12 +10,13 @@ toc: true
Alerts are available for any length of text, as well as an optional dismiss button. For proper styling, use one of the eight **required** contextual classes (e.g., `.alert-success`). For inline dismissal, use the [alerts jQuery plugin](#dismissing).
-{% example html %}
+{% capture example %}
{% for color in site.data.theme-colors %}
A simple {{ color.name }} alert—check it out!
{% endfor %}
-{% endexample %}
+{% endcapture %}
+{% include example.html content=example %}
{% include callout-warning-color-assistive-technologies.md %}
@@ -23,25 +24,27 @@ Alerts are available for any length of text, as well as an optional dismiss butt
Use the `.alert-link` utility class to quickly provide matching colored links within any alert.
-{% example html %}
+{% capture example %}
{% for color in site.data.theme-colors %}
A simple {{ color.name }} alert with an example link. Give it a click if you like.
{% endfor %}
-{% endexample %}
+{% endcapture %}
+{% include example.html content=example %}
### Additional content
Alerts can also contain additional HTML elements like headings, paragraphs and dividers.
-{% example html %}
+{% capture example %}
Well done!
Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.
Whenever you need to, be sure to use margin utilities to keep things nice and tidy.
-{% endexample %}
+{% endcapture %}
+{% include example.html content=example %}
### Dismissing
@@ -56,14 +59,15 @@ Using the alert JavaScript plugin, it's possible to dismiss any alert inline. He
You can see this in action with a live demo:
-{% example html %}
+{% capture example %}
Holy guacamole! You should check in on some of those fields below.
-{% endexample %}
+{% endcapture %}
+{% include example.html content=example %}
## JavaScript behavior
diff --git a/docs/4.0/components/badge.md b/docs/4.0/components/badge.md
index f8967921e0..0e97cbe763 100644
--- a/docs/4.0/components/badge.md
+++ b/docs/4.0/components/badge.md
@@ -30,31 +30,34 @@ Badges scale to match the size of the immediate parent element by using relative
Badges can be used as part of links or buttons to provide a counter.
-{% example html %}
+{% capture example %}
-{% endexample %}
+{% endcapture %}
+{% include example.html content=example %}
Note that depending on how they are used, badges may be confusing for users of screen readers and similar assistive technologies. While the styling of badges provides a visual cue as to their purpose, these users will simply be presented with the content of the badge. Depending on the specific situation, these badges may seem like random additional words or numbers at the end of a sentence, link, or button.
Unless the context is clear (as with the "Notifications" example, where it is understood that the "4" is the number of notifications), consider including additional context with a visually hidden piece of additional text.
-{% example html %}
+{% capture example %}
-{% endexample %}
+{% endcapture %}
+{% include example.html content=example %}
## Contextual variations
Add any of the below mentioned modifier classes to change the appearance of a badge.
-{% example html %}
+{% capture example %}
{% for color in site.data.theme-colors %}
{{ color.name | capitalize }}{% endfor %}
-{% endexample %}
+{% endcapture %}
+{% include example.html content=example %}
{% include callout-warning-color-assistive-technologies.md %}
@@ -62,16 +65,18 @@ Add any of the below mentioned modifier classes to change the appearance of a ba
Use the `.badge-pill` modifier class to make badges more rounded (with a larger `border-radius` and additional horizontal `padding`). Useful if you miss the badges from v3.
-{% example html %}
+{% capture example %}
{% for color in site.data.theme-colors %}
{{ color.name | capitalize }}{% endfor %}
-{% endexample %}
+{% endcapture %}
+{% include example.html content=example %}
## Links
Using the contextual `.badge-*` classes on an `` element quickly provide _actionable_ badges with hover and focus states.
-{% example html %}
+{% capture example %}
{% for color in site.data.theme-colors %}
{{ color.name | capitalize }}{% endfor %}
-{% endexample %}
+{% endcapture %}
+{% include example.html content=example %}
diff --git a/docs/4.0/components/breadcrumb.md b/docs/4.0/components/breadcrumb.md
index 2cbcc17b9e..9710f9a56c 100644
--- a/docs/4.0/components/breadcrumb.md
+++ b/docs/4.0/components/breadcrumb.md
@@ -9,7 +9,7 @@ group: components
Separators are automatically added in CSS through [`::before`](https://developer.mozilla.org/en-US/docs/Web/CSS/::before) and [`content`](https://developer.mozilla.org/en-US/docs/Web/CSS/content).
-{% example html %}
+{% capture example %}
-{% endexample %}
+{% endcapture %}
+{% include example.html content=example %}
## Accessibility
diff --git a/docs/4.0/components/button-group.md b/docs/4.0/components/button-group.md
index f02ded31b4..2261a5e729 100644
--- a/docs/4.0/components/button-group.md
+++ b/docs/4.0/components/button-group.md
@@ -10,13 +10,14 @@ toc: true
Wrap a series of buttons with `.btn` in `.btn-group`. Add on optional JavaScript radio and checkbox style behavior with [our buttons plugin]({{ site.baseurl }}/docs/{{ site.docs_version }}/components/buttons/#button-plugin).
-{% example html %}
+{% capture example %}
-{% endexample %}
+{% endcapture %}
+{% include example.html content=example %}
{% capture callout %}
##### Ensure correct `role` and provide a label
@@ -31,7 +32,7 @@ In addition, groups and toolbars should be given an explicit label, as most assi
Combine sets of button groups into button toolbars for more complex components. Use utility classes as needed to space out groups, buttons, and more.
-{% example html %}
+{% capture example %}
-{% endexample %}
+{% endcapture %}
+{% include example.html content=example %}
Feel free to mix input groups with button groups in your toolbars. Similar to the example above, you'll likely need some utilities though to space things properly.
-{% example html %}
+{% capture example %}
-{% endexample %}
+{% endcapture %}
+{% include example.html content=example %}
## Sizing
@@ -118,7 +121,7 @@ Instead of applying button sizing classes to every button in a group, just add `
Place a `.btn-group` within another `.btn-group` when you want dropdown menus mixed with a series of buttons.
-{% example html %}
+{% capture example %}
@@ -133,7 +136,8 @@ Place a `.btn-group` within another `.btn-group` when you want dropdown menus mi
-{% endexample %}
+{% endcapture %}
+{% include example.html content=example %}
## Vertical variation
diff --git a/docs/4.0/components/buttons.md b/docs/4.0/components/buttons.md
index 926bc46624..52922d0923 100644
--- a/docs/4.0/components/buttons.md
+++ b/docs/4.0/components/buttons.md
@@ -11,12 +11,13 @@ toc: true
Bootstrap includes several predefined button styles, each serving its own semantic purpose, with a few extras thrown in for more control.
-{% example html %}
+{% capture example %}
{% for color in site.data.theme-colors %}
{% endfor %}
-{% endexample %}
+{% endcapture %}
+{% include example.html content=example %}
{% include callout-warning-color-assistive-technologies.md %}
@@ -26,61 +27,68 @@ The `.btn` classes are designed to be used with the `