Sha256: 0ec0bfe61a6c3e6bede6beee74483971b57a721b4450f8902e5998b29b3de122
Contents?: true
Size: 1003 Bytes
Versions: 41
Compression:
Stored size: 1003 Bytes
Contents
module Locomotive module Steam module Liquid module Tags # Assign sets a variable in your session. # # {% session_assign foo = 'monkey' %} # # You can then use the variable later in the page. # # {{ session.foo }} # class SessionAssign < ::Liquid::Tag Syntax = /(#{::Liquid::VariableSignature}+)\s*=\s*(#{::Liquid::QuotedFragment}+)/o def initialize(tag_name, markup, options) if markup =~ Syntax @to, @from = $1, $2 else raise ::Liquid::SyntaxError.new("Valid syntax: session_assign [var] = [source]") end super end def render(context) request = context.registers[:request] request.session[@to.to_sym] = context[@from] '' end end ::Liquid::Template.register_tag('session_assign'.freeze, SessionAssign) end end end end
Version data entries
41 entries across 41 versions & 1 rubygems