Live data from Hacker News

Everything you need to understand to start with AngularJS

stephanebegaudeau.tumblr.com

21–30 of 31 posts

Re: Everything you need to understand to start with AngularJS

#22
post #14

If using with Django, is it possible to change the {{}} to something else?

Shameless plug: I wrote a short post on this exact subject two days ago[1]!

I also describe how to display the '{{' and '}}' strings in Jinja2, which is comically non-trivial :D

[1]: http://www.verdantrefuge.com/writing/2013/angularjs-custom-s...

Re: Everything you need to understand to start with AngularJS

#24
post #14

If using with Django, is it possible to change the {{}} to something else?

I don't know if it's possible but, in general, it's not a good idea to mix server-side and client-side templating. The Angular guys discuss this in one of the videos on the Angular channel (I found it for you here: http://www.youtube.com/watch?feature=player_detailpage&v... ). The two reasons seem to be first, it's not clean and second, it's easy to introduce security issues. If I want to have a page that has both se…

That security concern is nonsense. Use {% verbatim %} as noted below for angular templates (there's plenty of backports for Django <1.5). I have django templates fill in runtime parameters (csrf_tokens, etc) all the time.

Re: Everything you need to understand to start with AngularJS

#25

> In those expressions, you have access to Javascript code Just to clarify, double curly expressions in Angular, {{ }}, are "JS-like", basically a subset of JS + filter syntax. One goal of the expression syntax is to prevent a lot of app logic being stuck into the template itself, so the subset of JS is fairly minimal, but this is by design. This also means that the expressions are not eval()'d. Instead, they are par…

I'm curious about the speed hit of these parsed expressions. Do you know if they are pre-compiled into anonymous functions, or if they are parsed on the fly?

Re: Everything you need to understand to start with AngularJS

#26
post #9

Too bad it's relying on (blurry) snapshots vs. https://code.google.com/p/google-code-prettify

The blurry part isn't so nice, but I think that have snapshots of code might actually be better in a lot of ways if it forces people to type code out themselves without copy/paste (no better way to learn than to get it into your muscle memory after all).

Re: Everything you need to understand to start with AngularJS

#27
post #25

> In those expressions, you have access to Javascript code Just to clarify, double curly expressions in Angular, {{ }}, are "JS-like", basically a subset of JS + filter syntax. One goal of the expression syntax is to prevent a lot of app logic being stuck into the template itself, so the subset of JS is fairly minimal, but this is by design. This also means that the expressions are not eval()'d. Instead, they are par…

I'm curious about the speed hit of these parsed expressions. Do you know if they are pre-compiled into anonymous functions, or if they are parsed on the fly?

Was thinking the same thing. My guess is on-the-fly parsing.

Re: Everything you need to understand to start with AngularJS

#28
post #25

> In those expressions, you have access to Javascript code Just to clarify, double curly expressions in Angular, {{ }}, are "JS-like", basically a subset of JS + filter syntax. One goal of the expression syntax is to prevent a lot of app logic being stuck into the template itself, so the subset of JS is fairly minimal, but this is by design. This also means that the expressions are not eval()'d. Instead, they are par…

I'm curious about the speed hit of these parsed expressions. Do you know if they are pre-compiled into anonymous functions, or if they are parsed on the fly?

See: https://github.com/angular/angular.js/blob/9480136d9f062ec4b...

Looks like they are never interpreted, but there are (at least) two different compilation strategies: 1) Anonymous function with a loop 2) Fully compiled Function constructed via JavaScript source with the loop unrolled In general, this bit of code seems to be optimized to a crazy degree.

It's also worth noting that the "filters" part of the expression is maintained as a pipeline in an array, since filters may inform bidiectional binding behavior.

Re: Everything you need to understand to start with AngularJS

#30
post #26
post #9

Too bad it's relying on (blurry) snapshots vs. https://code.google.com/p/google-code-prettify

The blurry part isn't so nice, but I think that have snapshots of code might actually be better in a lot of ways if it forces people to type code out themselves without copy/paste (no better way to learn than to get it into your muscle memory after all).

There's no benefit to wasting time typing. Being a developer should assume a basic competency of typing, but anything that saves typing is a good thing.
Post reply on HN