Shortcodes in twig file?

Hi,
is it possible to use shortcodes in a html.twig file?
Should I use both lines (or only one of them) as described in your docs?

{{% embed page="/path-or-slug" modular=false|true template="name" %}}
{{% embed "/path-or-slug" modular=false|true template="name" %}}

For grav/twig beginners it’s not so easy to understand.
Maybe it’s possible to give a full example with result for the cookbook Plugins section?
Thanks!

I strongly suggest you read the Twig docs on the official site. They have a great walk through for designers:

http://twig.sensiolabs.org/doc/templates.html

Hi @arank,

Shortcodes cannot directly be mixed with Twig content. However, it implements a Twig function called shortcodes you can use in your Twig files, e.g.

{{ shortcodes("{{% embed '/path-to-your-page' %}}") }}

But be warned! Some shortcodes may not work as expected, when using them in this way.

If you really like to embed content from other pages from a twig file, then I strongly recommend to use the following Twig snippet

{{ pages.find('/path-to-your-page').content }}

Hi, thanks. Exactly what I was looking for.

I have a modular page. So the path should be:
/usr/pages/01.home/_test
But the content isn’t shown???
Wrong path?

Hi @arank,

yeah that’s most possibly the wrong path. Usually you have to insert the path you can see from the browser for a specific page, i.e. for a page you can access it via

http://mysite.com/my-super-page

you have to write

{{ pages.find('/my-super-page').content }}

and for modular content

{{ pages.find('/my-super-page/_modular').content }}

(in your case the slug is maybe /home/_test or just /_test). I haven’t tried it, but it is really difficult to tell you the correct path, when I don’t know how your folder structure looks like.