This repository has been archived by the owner on Dec 27, 2018. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Macros (shortcodes) feature. (#371)
- Loading branch information
1 parent
e660fc2
commit d21ac52
Showing
7 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{% macro youtube(id) %} | ||
<div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;"> | ||
<iframe src="//www.youtube.com/embed/{{ id }}?autoplay=1" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" allowfullscreen title="YouTube Video"></iframe> | ||
</div> | ||
{% endmacro %} | ||
|
||
{% macro gist(user, id) %} | ||
<script type="application/javascript" src="//gist.github.com/{{ user }}/{{ id }}.js"></script> | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{% set macros = "{% import 'macros.twig' as macro %}" %} | ||
{{ include(template_from_string(macros ~ page.content)) }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
tests/fixtures/website/content/Macros-and-variables/macros.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
title: Macros | ||
layout: macro.html | ||
--- | ||
# Macros in Markdown | ||
|
||
## Youtube video | ||
{{ macro.youtube('NaB8JBfE7DY') }} | ||
|
||
## GitHub Gist | ||
{{ macro.gist('Narno', 'fbe791e05b93951ffc1f6abda8ee88f0') }} |
13 changes: 13 additions & 0 deletions
13
tests/fixtures/website/content/Macros-and-variables/variables.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
title: Variables | ||
layout: macro.html | ||
var1: 'var 1' | ||
--- | ||
# Variables in Markdown | ||
|
||
## Set and show | ||
{% set foo = 'bar' %} | ||
foo: `{{ foo }}` | ||
|
||
## FM variable | ||
page.var1: `{{ page.var1 }}` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{% extends '_default/page.html.twig' %} | ||
|
||
{% block content %} | ||
{# page.content #} | ||
{% include page.content_template %} | ||
{% endblock %} |