2018-03-14 16:44:38 +01:00
|
|
|
{%- comment -%}
|
2018-11-16 16:52:02 +01:00
|
|
|
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)
|
2018-03-14 16:44:38 +01:00
|
|
|
{%- endcomment -%}
|
|
|
|
|
2018-11-16 16:52:02 +01:00
|
|
|
{%- assign id = include.id -%}
|
|
|
|
{%- assign class = include.class -%}
|
2018-03-14 16:44:38 +01:00
|
|
|
|
|
|
|
{%- if include.hide_preview == null -%}
|
2018-11-16 16:52:02 +01:00
|
|
|
<div{% if id %} id="{{ id }}"{% endif %} class="bd-example{% if class %} {{ class }}{% endif %}">
|
2018-03-14 16:44:38 +01:00
|
|
|
{{- include.content -}}
|
|
|
|
</div>
|
|
|
|
{%- endif -%}
|
|
|
|
|
|
|
|
{%- if include.hide_markup == null -%}
|
|
|
|
{%- highlight html -%}
|
2018-11-14 14:10:23 +01:00
|
|
|
{%- if include.content contains '<svg class="bd-placeholder-img' -%}
|
2018-11-11 13:45:48 +01:00
|
|
|
{%- assign modified_content = include.content
|
2018-11-14 14:10:23 +01:00
|
|
|
| replace: '<svg class="bd-placeholder-img', '✂️<svg class="bd-placeholder-img'
|
|
|
|
| replace: '</svg>', '</svg>✂️'
|
2018-11-11 13:45:48 +01:00
|
|
|
| split: '✂️' -%}
|
|
|
|
|
2018-11-14 14:10:23 +01:00
|
|
|
{%- 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] -%}
|
|
|
|
|
2018-11-11 13:45:48 +01:00
|
|
|
{%- for content_chunk in modified_content -%}
|
2018-11-14 14:10:23 +01:00
|
|
|
{%- 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 -}}
|
2018-11-11 13:45:48 +01:00
|
|
|
{%- else -%}
|
|
|
|
{{- content_chunk -}}
|
|
|
|
{%- endif -%}
|
|
|
|
{%- endfor -%}
|
|
|
|
{%- else -%}
|
|
|
|
{{- include.content -}}
|
|
|
|
{%- endif -%}
|
2018-03-14 16:44:38 +01:00
|
|
|
{%- endhighlight -%}
|
|
|
|
{%- endif -%}
|