Sha256: 8843dd0b4c56c25aed4d402b65be0a021280ed7b9f5bea4a15a81af3fce44e57
Contents?: true
Size: 1.01 KB
Versions: 15
Compression:
Stored size: 1.01 KB
Contents
module Locomotive module Wagon 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}+)/ def initialize(tag_name, markup, tokens, options) if markup =~ Syntax @to = $1 @from = $2 else raise ::Liquid::SyntaxError.new(options[:locale].t("errors.syntax.session_assign"), options[:line]) 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', SessionAssign) end end end end
Version data entries
15 entries across 15 versions & 1 rubygems