How to use tangible_template() function

Hi Eliot!
I’m wondering about the PHP function that’s mentioned on the Templates page of the documentation. Can I use it to load a template in a PHP file? What variables do I need to pass to it?

Thanks!

Yes - it can render a template directly, like do_shortcode.

echo tangible_template('<Field title />');

…Or load a template from a file:

echo tangible_template()->load_file( __DIR__ . '/example.html' );

This requires the full path to the file, so the __DIR__ constant is used to get the template path relative to the current PHP file.


OK, I added the above (and how to load template post) to the documentation site here: https://loop.tangible.one/tags/template#php

1 Like