Skip to main content

Transcript

In this video, you'll continue the Render function you started in the last video.

You will replace the test values with part of the Config file that your partner is creating.

Click the Config file to see the code your partner is writing.

Your partner may not have finished this code.

That's okay.

You can still write your part of the code and test it even if they are not finished.

The Config file stores the URLs and names of the posters you and your team members built in the last activity.

The Config file contains a variable called "posters." In it, there are three posters, each with a URL and a name.

To test your part of the code, make a poster variable with two components: URL and name.

This variable allows you to test your render code separately from the Config piece that your teammate is working on.

Once your render code works and your teammate completes the config file, you will change your poster variable again.

To define the poster variable for your test, start a new line in your program underneath the var template line.

Type "var, space, poster, space, equals, space, left curly brace, URL, colon." Then, "space, double quotation marks, URL, space, test." Add a comma and a space, then type "name, colon, space, double quotation mark, name, space, test." Close the variable.

Check to be sure your code looks exactly like what is on the screen.

Remove the quotation marks around "poster.url" and "poster.name." Now the computer will use a poster URL and a poster name from the stored poster variable.

Run your program again and check the logs.

These variables now reference the values you created above.

The poster URL should appear in the HTML as "url test" and the name will appear as "name test." At this point, you have completed three of the four steps you need for the "render.gs" code.

So far you have: created a template variable to hold the HTML page, added a test poster url and test poster name to the template, and created a version of the template with the variables.

Next, tell the computer to get the Poster URL and Poster Name from the Config file.

Earlier, you hardcoded the poster variable.

Now, use the "Choose Poster number" function in place of this variable.

Add two forward slashes before "var poster" to comment out that line.

The computer will ignore this line of code, but if your program stops working, you can easily use the variable again.

Then, redefine the poster variable so that it gets the values from the Config file.

Type "var, space, poster, space, equals, posters." Add an open square bracket.

Type "choose poster number" and add parentheses.

End the line with a semicolon.

Now, run your code.

If you get a error, your partner may not be finished with their part of the code.

That's okay.

You can still work on your part of the code.

If your partner has finished the config code the logs contain the name and URL for a random poster.

Finally, return the template to render the webpage.

Below "Logger.log," type "return, space, template.evaluate." Then, add open and closed parentheses.

End the line with a semicolon.

Run your program once more to check for errors.

You won't be able to see the web page until you publish it in the next video.

Before publishing your web page, you will want to check the tests for errors.

Tests are separate programs used to try out sections of code.

Testing only your section ensures that a bug in one person's code will not affect your testing.

In your starter project is a test file.

Open "tests.gs".

Do not alter any part of this code.

Select the Test Render function and run the code.

Then, check the code log.

See if the program returns any errors.

If it doesn't, then you're ready to move on.

If it does, check the message and look at your code to see if you can identify the error.

Once you're finished writing the Render code, check on your group members to see if they need help.

Then, when you are all ready, move on to publish your group's code.

Now, it's your turn: Replace the test values with information from the Config file.

Test your program using the render test function in "render.gs."


Instructions

  1. Replace the test values with information from the config file.
  2. Test your program using the render test function in render.gs