Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Templating with Twig Templating Languages Twig View

Peng Yu
PLUS
Peng Yu
Courses Plus Student 64 Points

Quiz Question 3 of 5 answer

Hi everyone. may I ask if anyone could know the correct answer for "Templating with Twig", first quiz Question 3? (question as below)

Please fill in the correct answer in each blank provided below.

Complete the code to execute the code from the "testimonials.twig" file.

<?php require_once ⎽⎽DIR⎽⎽ . '/../vendor/autoload.php'; $loader = new Twig_Loader_Filesystem('templates', getcwd().'/..'); $twig = new Twig_Environment($loader, array('debug' => true, 'auto_reload' => true)); __(here is the blank that needs to be filled in)

Thank you very much for your time.

1 Answer

Steven Parker
Steven Parker
229,967 Points

Try the "Review Video" button, and look at the examples given there.
Another hint: since you don't know what the contents of the loaded file are, you shouldn't provide any data.

Peng Yu
Peng Yu
Courses Plus Student 64 Points

Thank you Steven, I have tried: echo $twig->render('testimonials.twig', []); echo $twig->render('testimonials.twig', array());

but they both are wrong, and I have searched on google as well but didn't help... wondering if the syntax is wrong? If its possible, Could you check if anything is not right in my answers? Very much appreciated your time and kindness:)

Steven Parker
Steven Parker
229,967 Points

Instead of supplying an empty data array, just don't provide a 2nd argument at all.