Scenario for using instance vars to pass data to layouts and templates, and prevent
changes to instance vars being shared between different templates.
This commit is contained in:
parent
9b07bf24dd
commit
97dc2c9742
7 changed files with 41 additions and 6 deletions
5
fixtures/instance-vars-app/source/_vartial.erb
Normal file
5
fixtures/instance-vars-app/source/_vartial.erb
Normal file
|
@ -0,0 +1,5 @@
|
|||
<% if @my_var %>
|
||||
My var is here!
|
||||
<% else %>
|
||||
No var...
|
||||
<% end %>
|
|
@ -0,0 +1,2 @@
|
|||
<% @my_var = 100 %>
|
||||
<%= partial 'vartial' %>
|
3
fixtures/instance-vars-app/source/layout.erb
Normal file
3
fixtures/instance-vars-app/source/layout.erb
Normal file
|
@ -0,0 +1,3 @@
|
|||
Var is <%= @my_var %>
|
||||
|
||||
<%= yield %>
|
|
@ -0,0 +1 @@
|
|||
<%= partial 'vartial' %>
|
Loading…
Add table
Add a link
Reference in a new issue