What is the twig equivalent to this php snippet?

I have a simple php call to insert content from a local non-php script. Twig isn’t making any sense to me and PHP is far from my normal scripting language. Does anyone know what the twig equivalent to this is?

<?php echo readfile('http://somedomain.com/somescript.mvc'); ?>

Thanks. I’m enjoying getting to know grav apart from having to deal with scripting languages that I’ve never seen before. Also, please don’t say “creat a plugin” - I do not have time for it at the moment.

I tried putting this on the page:

{% include ‘http://somedomain.com/somescript.mvc’ %}

but it just prints it out as is. I don’t want to put this in a template because it’s only for the home page. I’m used to be able to script inside the page which makes it super easy to customize stuff on a page by page basis. Is this not really possible in grav?

You’d really have to create a plugin to read the file - sorry - as Twig’s includes are purposed towards including templates. The .mvc file (not sure what format that is) would have to be parsed beforehand, or including it with Twig does very little.

The mvc file is already parsed, the output is straight up HTML.

Is it possible to make a template for the home page only? That would be a step. It would be nice if you guys had a plugin avialable to inject remote content like this in it’s raw form (no iframes or third party go-betweens), I’m sure it would be useful for a lot of people.

You can make as many templates as you want, so yes, you can have a template you only use for the home page and a different one for the other pages…or a different template for every page, for that matter.

Twig does not natively support remote includes. You would either have to write a twig extension plugin—à la something like this—or a simpler plugin that fetches and injects the content—see the plugin cookbook. I’m afraid a plugin of some kind or another is unavoidable in this use case.

If I have some time, I may try to code a generic remote fetch solution, but it may not serve your purposes. I would start with a simple shortcode that fetches and displays response body content.

I figured out a work around by updating my script to export csv files and then using jquery to get and display the data. You know how it goes- when something’s been working for a while I’d like to just use it instead of spending a bunch of dev time on it. I will look into the templates and plugins in more depth when I get a chance, though. Thanks for your help and suggestions.