Class: Locomotive::Steam::Liquid::Tags::SessionAssign
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Locomotive::Steam::Liquid::Tags::SessionAssign
- Defined in:
- lib/locomotive/steam/liquid/tags/session_assign.rb
Overview
Assign sets a variable in your session.
{% session_assign foo = 'monkey' %}
You can then use the variable later in the page.
{{ session.foo }}
Constant Summary collapse
Instance Method Summary collapse
-
#initialize(tag_name, markup, options) ⇒ SessionAssign
constructor
A new instance of SessionAssign.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, markup, options) ⇒ SessionAssign
Returns a new instance of SessionAssign.
17 18 19 20 21 22 23 24 25 |
# File 'lib/locomotive/steam/liquid/tags/session_assign.rb', line 17 def initialize(tag_name, markup, ) if markup =~ Syntax @to, @from = $1, $2 else raise ::Liquid::SyntaxError.new("Valid syntax: session_assign [var] = [source]") end super end |
Instance Method Details
#render(context) ⇒ Object
27 28 29 30 31 |
# File 'lib/locomotive/steam/liquid/tags/session_assign.rb', line 27 def render(context) request = context.registers[:request] request.session[@to.to_sym] = context[@from] '' end |