djangochicagoboss

"context" can not be used ChicagoBoss Template Tags


After upgrading ChicagoBoss to latest version (i.e.from 0.8.10 -> 0.8.14). I have been observing that the term "context" can not be used in any of the chicagoboss template tags.

Its giving syntax error :

eg.

{% if context == data.code %}
          <option selected>{{data.value1}}</option>
{% else %}
          <option selected>{{data.value2}}</option>
{% endif %}

OR

{% url action="some_action" context=data.val %}

And same error thrown for these template tags :

Unhandled Error: error:{case_clause,{ok,[{"src/view/x_return/form_12.html",
                         [{{88,15},
                           erlydtl_parser,
                           ["syntax error before: ",["\"context\""]]}]}]}} Stacktrace: [{boss_web_controller_render,render_view,5,[{file,"src/boss/boss_web_controller_render.erl"},{line,217}]},{boss_web_controller,execute_action_inner,9,[{file,"src/boss/boss_web_controller.erl"},{line,290}]},{boss_web_controller_handle_request,process_dynamic_request,5,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,254}]},{boss_web_controller_handle_request,process_request,5,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,240}]},{boss_web_controller_handle_request,set_timer,8,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,160}]},{boss_web_controller_handle_request,build_dynamic_response,5,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,129}]},{boss_web_controller_handle_request,handle_request,4,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,26}]},{mochicow_upgrade,upgrade,4,[{file,"src/mochicow_upgrade.erl"},{line,72}]}]

It works pretty fine when I change "context" to "cntxt" or anything other than context.

As you may know that ChicagoBoss tags is just similar to Django template tags. Since I followed ChicagoBoss as well as Django documentation but I could not see any documentation that "context" is keyword or any reserved term.

Note - I do have many files containing "context" used in template tags. Since not a good idea to update each file to change the term manually.


Solution

  • context changed bing a reserved keyword in erlydtl (the Erlang implementation of the Django Template Language) in version 0.9.4, see: https://github.com/erlydtl/erlydtl/releases/tag/0.9.4

    So when you updated your ChicagoBoss, as a dependency you probably pulled a erlydtl versoin >= 0.9.4

    You could recompile ChicagoBoss after configuring a lower tag version of erlydtl in the rebar.config in the root directory of your ChicagoBoss. As an example, if you want version 0.9.3, put:

    {erlydtl, ".*", {git, "git://github.com/erlydtl/erlydtl.git", {tag, "0.9.3"}}}