0

I have been using Google app engine to host my web pages where I rehearse my coding skills. My site is built on top of Foundation framework. I started playing around with Angular and the appengine returns an error message:


Traceback (most recent call last): 
File "/base/data/home/runtimes/python/python_lib/versions/1/google/appengine/ext/webapp/_webapp25.py", line 714, in __call__handler.get(*groups)
File "/base/data/home/apps/s~verkkolakimies/1.374513895376995789/main.py", line 16, in get self.response.out.write (template.render (path, {}))
File "/base/data/home/runtimes/python/python_lib/versions/1/google/appengine/ext/webapp/template.py", line 91, in render
t = _load_user_django(template_path, debug)
File "/base/data/home/runtimes/python/python_lib/versions/1/google/appengine/ext/webapp/template.py", line 113, in _load_user_django
template = django.template.loader.get_template(file_name)
File "/base/data/home/runtimes/python/python_lib/versions/third_party/django-0.96/django/template/loader.py", line 80, in get_template
template = get_template_from_string(source, origin, template_name)
 File "/base/data/home/runtimes/python/python_lib/versions/third_party/django-0.96/django/template/loader.py", line 88, in get_template_from_string
return Template(source, origin, name)
File "/base/data/home/runtimes/python/python_lib/versions/third_party/django-0.96/django/template/__init__.py", line 158, in __init__
self.nodelist = compile_string(template_string, origin)
File "/base/data/home/runtimes/python/python_lib/versions/third_party/django-0.96/django/template/__init__.py", line 174, in compile_string
return parser.parse()
File "/base/data/home/runtimes/python/python_lib/versions/third_party/django-0.96/django/template/__init__.py", line 254, in parse
filter_expression = self.compile_filter(token.contents)
File "/base/data/home/runtimes/python/python_lib/versions/third_party/django-0.96/django/template/__init__.py", line 338, in compile_filter
return FilterExpression(token, self)
File "/base/data/home/runtimes/python/python_lib/versions/third_party/django-0.96/django/template/__init__.py", line 558, in __init__
raise TemplateSyntaxError, "Could not parse the remainder: %s" % token[upto:]
TemplateSyntaxError: Could not parse the remainder:  + " "+ sukunimi

I traced the issue to adding angular code:

 <div class="panel radius">
 Vainajan nimi: {{etunimi + " "+ sukunimi}}<br>
 Tyttönimi: {{tyttonimi}}<br>
 Henkilötunnus: {{vainaja_hetu}}<br>
 Ammatti: {{ammatti}}<br>
 Syntynyt: {{vainaja_hetu}}<br> Kuollut: {{deathDate}} <br>
 Postinumero: {{zip}}
 </div>

I am getting the angular data from the same page form:

  <form action="#" method="POST" name="perukirjakone" ng-init="sukunimi=juttu; etunimi=tuttu">
    <fieldset id="perittäväSet" class="color3">
      <legend class="fi-info"> XXX</legend>

      <label for="vainaja_first_name" >Vainajan etunimi</label><br>
      <input  type="text" required name="vainaja_first_name" id="vainaja_first_name" tabindex="1" placeholder="Esa" ng-model="etunimi"> 

Are the two curly braces throwing the Python off or should I look for other leaks in my code? I guess my question is that that are there known problems with Angular and GAE?

Robin Andersson
  • 5,150
  • 3
  • 25
  • 44
blindJustice
  • 235
  • 3
  • 5
  • This one looks strange to me: {{etunimi + " "+ sukunimi}} Solution: {{ etunimi }} {{ sukunimi}} ??? – voscausa Mar 18 '14 at 21:05
  • @voscausa {{etunimi + " "+ sukunimi}} is perfectly fine in AngularJS. – Robin Andersson Mar 18 '14 at 21:07
  • Sorry. It looked like django templating to me. If you are useing django you have to escape the django translation. Look for django verbatim to escape Angular code. – voscausa Mar 18 '14 at 21:10
  • I found this post to be helpful too: [link](http://stackoverflow.com/questions/8302928/angularjs-with-django-conflicting-template-tags?lq=1) – blindJustice Mar 19 '14 at 08:17

2 Answers2

4

This is not related to App Engine, it is related to Django which is the framework you use.

Django also use double curly brackets in their templates which makes it conflict with AngularJS.

See: AngularJS with Django - Conflicting template tags

Community
  • 1
  • 1
Robin Andersson
  • 5,150
  • 3
  • 25
  • 44
1

Robin has it. Both Django templates and Angular want to use {{. There's advice for working around that, and for working around some other Django/Angular issues, in http://django-angular.readthedocs.org/en/latest/integration.html

I've only used Angular with GAE a few times, and found that isolating the Angular parts into static files, and using GAE to serve up Ajax requests, worked quite well.

Dave W. Smith
  • 24,318
  • 4
  • 40
  • 46