Permalink
Browse files

Pass session data to views

  • Loading branch information...
1 parent 2adcead commit c5b170bfb97aae83ae2bce4ec4d31d5fe8c170ee @evanmiller evanmiller committed Jul 9, 2012
Showing with 5 additions and 3 deletions.
  1. +3 −2 doc-src/api-view.html
  2. +2 −1 src/boss/boss_web_controller.erl
View
@@ -20,8 +20,9 @@
<h2>Implicit variables</h2>
<p>The following variables are automatically passed to your views without you doing any work:</p>
<ul>
- <li><code>_lang</code> - The content language of the rendered view</li>
- <li><code>_before</code> - The result of the authorization filter, if present</li>
<li><code>_base_url</code> - The value of the config setting "base_url" or blank if not set</li>
+ <li><code>_before</code> - The result of the authorization filter, if present</li>
+ <li><code>_lang</code> - The content language of the rendered view</li>
+ <li><code>_session</code> - Key/value pairs from the current session, if it exists</li>
</ul>
{% endblock %}
@@ -732,12 +732,13 @@ render_view({Controller, Template, _}, AppInfo, Req, SessionID, Variables, Heade
ViewPath = boss_files:web_view_path(Controller, Template),
LoadResult = boss_load:load_view_if_dev(AppInfo#boss_app_info.application, ViewPath, AppInfo#boss_app_info.translator_pid),
BossFlash = boss_flash:get_and_clear(SessionID),
+ SessionData = boss_session:get_session_data(SessionID),
case LoadResult of
{ok, Module} ->
{Lang, TranslationFun} = choose_translation_fun(AppInfo#boss_app_info.translator_pid,
Module:translatable_strings(), Req:header(accept_language),
proplists:get_value("Content-Language", Headers)),
- case Module:render(lists:merge([{"_lang", Lang},
+ case Module:render(lists:merge([{"_lang", Lang}, {"_session", SessionData},
{"_base_url", AppInfo#boss_app_info.base_url}|Variables], BossFlash),
[{translation_fun, TranslationFun}, {locale, Lang},
{custom_tags_context, [

0 comments on commit c5b170b

Please sign in to comment.