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 trialPeng Yu
Courses Plus Student 64 PointsQuiz 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
231,271 PointsTry 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
Courses Plus Student 64 PointsPeng Yu
Courses Plus Student 64 PointsThank 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
231,271 PointsSteven Parker
231,271 PointsInstead of supplying an empty data array, just don't provide a 2nd argument at all.
Peng Yu
Courses Plus Student 64 PointsPeng Yu
Courses Plus Student 64 PointsThank you so much Steven!!!