diff --git a/lib/locomotive/liquid/drops/current_user.rb b/lib/locomotive/liquid/drops/current_user.rb new file mode 100644 index 00000000..bfa05c8f --- /dev/null +++ b/lib/locomotive/liquid/drops/current_user.rb @@ -0,0 +1,23 @@ +module Locomotive + module Liquid + module Drops + class CurrentUser < Base + + include ::Rails.application.routes.url_helpers + + def logged_in? + _source.present? + end + + def name + _source.name if logged_in? + end + + def email + _source.email if logged_in? + end + + end + end + end +end diff --git a/lib/locomotive/render.rb b/lib/locomotive/render.rb index 3e23d3bc..821abaaa 100644 --- a/lib/locomotive/render.rb +++ b/lib/locomotive/render.rb @@ -55,7 +55,8 @@ module Locomotive 'today' => Date.today, 'locale' => I18n.locale, 'default_locale' => current_site.default_locale.to_s, - 'locales' => current_site.locales + 'locales' => current_site.locales, + 'current_user' => Locomotive::Liquid::Drops::CurrentUser.new(current_locomotive_account) } assigns.merge!(Locomotive.config.context_assign_extensions) @@ -105,4 +106,4 @@ module Locomotive end end -end \ No newline at end of file +end