ERB Template Syntax Basics
📖 Scenario: You are building a simple webpage for a small bakery. You want to display a welcome message and a list of your top 3 favorite pastries using Ruby on Rails with ERB templates.
🎯 Goal: Create an ERB template that shows a greeting message and dynamically lists the pastry names using ERB syntax.
📋 What You'll Learn
Create a Ruby array called
pastries with exactly these strings: "Croissant", "Eclair", "Macaron"Create a string variable called
greeting with the exact value "Welcome to Sweet Treats Bakery!"Use ERB output tags
<%= %> to display the greeting inside an <h1> tagUse ERB control flow tags
<% %> with a for loop to iterate over pastries and display each pastry inside an <li> tag within a <ul>💡 Why This Matters
🌍 Real World
ERB templates are used in Ruby on Rails to create dynamic HTML pages that change based on data from Ruby code.
💼 Career
Understanding ERB syntax is essential for Rails developers to build interactive and data-driven web applications.
Progress0 / 4 steps