0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-12-03 15:24:19 +01:00
Bootstrap/site/_includes/example.html
2018-11-20 21:31:28 +02:00

58 lines
2.0 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{%- comment -%}
Usage: include example.html content=markup [args],
where content is a capture with the HTML content
args can be one of the following:
id - null (default)
class - "bd-example" (default)
optional: hide_preview - disabled (default)
optional: hide_markup - disabled (default)
{%- endcomment -%}
{%- assign id = include.id -%}
{%- assign class = include.class -%}
{%- if include.hide_preview == null -%}
<div{% if id %} id="{{ id }}"{% endif %} class="bd-example{% if class %} {{ class }}{% endif %}">
{{- include.content -}}
</div>
{%- endif -%}
{%- if include.hide_markup == null -%}
{%- highlight html -%}
{%- if include.content contains '<svg class="bd-placeholder-img' -%}
{%- assign modified_content = include.content
| replace: '<svg class="bd-placeholder-img', '<svg class="bd-placeholder-img'
| replace: '</svg>', '</svg>✂️'
| split: '✂️' -%}
{%- if include.content contains 'bd-placeholder-img ' -%}
{%- assign image_class = include.content
| replace_first: 'bd-placeholder-img', 'bd-placeholder-img ✂️'
| replace: '" width="', '✂️" width="'
| split: '✂️' -%}
{%- assign image_class = image_class[1] | replace: 'bd-placeholder-img-lg', '' | strip -%}
{%- endif -%}
{%- assign image_alt = include.content
| replace: '<title>', '<title>✂️'
| replace: '</title>', '✂️</title>'
| split: '✂️' -%}
{%- assign image_alt = image_alt[1] -%}
{%- for content_chunk in modified_content -%}
{%- if content_chunk contains '<svg class="bd-placeholder-img' -%}
{%- capture img_placeholder -%}
<img src="..." {% if image_class %}class="{{ image_class }}" {% endif %}alt="{{ image_alt }}">
{%- endcapture -%}
{{- img_placeholder -}}
{%- else -%}
{{- content_chunk -}}
{%- endif -%}
{%- endfor -%}
{%- else -%}
{{- include.content -}}
{%- endif -%}
{%- endhighlight -%}
{%- endif -%}