Displaying a single result out of three results I have a view block that is set up to produce three product titles sorted from a taxonomy term (flowers). I have a view whose machine name is latest_products.
In a preprocess function I use the following code.
$variables['views_twig_var'] = views_embed_view('latest_products','block_1');

In a template, I use {{ views_twig_var }}, which produces all three titles on the page.
If it's possible, how would I use it in the template file to only show the first result?
{{ views_twig_var[0] }} doesn't work.
I would then use the second result further down the page, with the final result even further down.
For now, I created it in three different blocks, with each block producing a single result, but for my curiosity and for future reference I am wondering if there is a faster way.
you can do it without preprocess, by using the Twig Tweak module, it gives you the possibility to render your view in twig with display filters and so on like the following:
{{ drupal_view_result('latest_products', 'block_1') }}

The drupal_view_result give you the array of result so you can get the first result with:
{{ drupal_view_result('latest_products', 'block_1')[0] }}

of type ResultRow and then get the entity with:
{{ drupal_view_result('latest_products', 'block_1')[0]._entity }}

For more information see the module Cheat sheet page