Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Use plugins in twig files

Started by Muut Archive 11 years ago · 4 replies · 359 views
11 years ago

Hello, i can't find a way to use plugin Youtube or MediaEmbed in twig file. I want set youtube urls in the page header

YAML
title: 2009
youtubes:
    - header: Video1
      url: https://www.youtube.com/watch?v=BK8guP9ov2U
    - header: Video2
      url: https://www.youtube.com/watch?v=BK8guP9ov2U

And use them in twig

TWIG
  {% for youtube in page.header.youtubes %}
          {% if youtube.header %}
            <h6>{{ youtube.header }}</h6>
          {% endif %}
          {% if youtube.url %}
              [plugin:youtube]({{ youtube.url }})
          {% endif %}
  {% endfor %}

BTW I set in system.yaml "pages: process: twig: true", but no luck.

11 years ago

Typically twig is processed after markdown is processed. In your case, your trying to dynamically put a twig variable into markdown syntax. You just need to tell Grav to process the Twig first with the header option:

TXT
twig_first: true
11 years ago

Thank you for your answer! Main thing that

TWIG
[plugin:youtube]({{ youtube.url }})

in twig do not applyed Just show

TXT
[plugin:youtube](https://www.youtube.com/watch?v=BK8guP9ov2U)

Is there special tag for youtube plugin in twig?

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1333 9 years ago
Archive · by Muut Archive, 9 years ago
2 924 9 years ago
Archive · by Muut Archive, 9 years ago
2 4055 9 years ago
Archive · by Muut Archive, 9 years ago
1 2933 9 years ago
Archive · by Muut Archive, 9 years ago
3 1110 9 years ago