Slide 1

Slide 1 text

ERB Embedded Ruby

Slide 2

Slide 2 text

Part of the Std-lib

Slide 3

Slide 3 text

Hello, World!

Slide 4

Slide 4 text

Execute

Slide 5

Slide 5 text

Output

Slide 6

Slide 6 text

Comments

Slide 7

Slide 7 text

Loops

Slide 8

Slide 8 text

$SAFE • `nil` means do nothing • Anything else runs the code in a thread and uses that particular safe mode. • What are safe modes?

Slide 9

Slide 9 text

Trim Modes • % enables Ruby code processing for lines beginning with % • <> omit newline for lines starting with <% and ending in %> • > omit newline for lines ending in %> • - omit blank lines ending in -%>

Slide 10

Slide 10 text

ERB::Util

Slide 11

Slide 11 text

Rails • Looks for your templates to have a “erb” extension. • Automatically turns on “-“ trim mode. • Automatically imports instance variables from your controller action. • Also imports `locals` passed in a `render` call.