Sha256: 04864ae000aba698e3146e402eb684c66c5cabac467f427be07c9803c6b6013e
Contents?: true
Size: 1004 Bytes
Versions: 13
Compression:
Stored size: 1004 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
13 entries across 13 versions & 1 rubygems