5 ms·
I have a hard time adopting frameworks because of the all-or-nothing aspect of them. If you use Angular, you have to use their templating language, right? I kno
by jlongster 13y ago
I have a hard time adopting frameworks because of the all-or-nothing aspect of them. If you use Angular, you have to use their templating language, right? I know that they do a lot of powerful things with it, but honestly it's difficult for me to throw away all of my current tools. It's just too much of a jump.
There's so much I love about libraries like angular and ember, but I'd love it if someone was working on a way to allow additional templating languages. I don't know how it would work, but you could possible compile other templates down to angular templates.
I've been thinking of a way to convert simple templates in angular's style, so that you can do all the cool auto-updating features. If there was a standard for this, templates like mustache, etc could compile a subset down to it.
Disclaimer: I'm the creator of nunjucks https://github.com/jlongster/nunjucks https://github.com/jlongster/nunjucks.
- deleted 13y ago[deleted]
- joelhooks 13y agoI've used Jade and Angular in the past. Angular allows you to change the bracket notation to something custom, which helps avoid conflicts. For the type of app I've been working on, the all-or-nothing hasn't been a real hindrance, but Angular is definitely a Framework and not so much a modular toolkit (like Backbone, for instance, which I would say is generally a better choice if you want to build something "custom")
- nahname 13y agoThe way most developers work with JavaScript (especially jQuery) is fundamentally broken and untestable. This was one of the most difficult things I fought with when using backbone and introducing developers to backbone. You can work with it the way that you know, but that is the hard way. It will make team scaling more difficult than it needs to be and you will be missing out on what the majority of the framework does for you. This is a major reason why I am coming around to Angular. Take away jQuery and developers have to stop and think. It makes it difficult to rush ahead chaining dozens of callbacks and tightly coupling their code to the DOM, in the familiar jQuery way. This, above all else, is what allows you to create a single page web application. The rest is just gravy on top.
- crabasa 13y agoIt's easy to tell Angular to use different syntax for interpolation: myModule.config(function($interpolateProvider) { $interpolateProvider.startSymbol('START'); $interpolateProvider.endSymbol('STOP'); }); However, you should be very cautious with mixing server-side and client-side templating. See: http://stackoverflow.com/a/11108407/476286 http://stackoverflow.com/a/11108407/476286
- jlongster 13y agoThat's an interesting approach, but I'm assuming this only works with variables, and you can't use loops or anything else. That might get you most of the way there though. I can't speak from any experience with angular, so this is about all I can say. I think it's great for one-page apps, but otherwise I enjoy writing templates without thinking too much if they are rendered server-side or client-side.
- crabasa 13y agoIt is for variables, but that's just because Angular has such an elegant way of iterating through loops: <li ng-repeat="friend in friends"> {{friend.name}} who is {{friend.age}} years old. </li> It's the ng-directive, and it's just one example of why directives are so awesome and powerful: http://docs.angularjs.org/guide/directive http://docs.angularjs.org/guide/directive
- sigil 13y agoI'm in the same boat as you. I like the looks of Angular, but not sure I want the client-side lock-in. I enjoy writing templates without thinking too much if they are rendered server-side or client-side. Funny, I've been considering this architecture: client :: js + your nunjucks library for templating server :: python + jinja2 for templating Are nunjucks and jinja2 pretty compatible now, to the point that you're actually sharing templates across client and server? The docs currently discourage it: http://nunjucks.jlongster.com/#Can-I-share-templates-between-Python%252Fjinja2-and-javascript%252Fnunjucks%253F http://nunjucks.jlongster.com/#Can-I-share-templates-between...
- voidfiles 13y agoIt's not just your tools though. They are asking you to throw away many of your ideas about web development as well. They ask you to adopt a new paradigm that doesn't fit in with the template, innerHTML style of development. If you embrace that idea, and go with the flow, you can do some amazing things amazingly fast with angular that doesn't work so well in other frameworks.
- sshconnection 13y agoYou can switch the template engine in Ember, but you'll lose the databinding hotness unless you implement it in your own engine.
- tmzt 13y agoYeah, still waiting for jade support but haven't looked at how to implement one yet.
- avolcano 13y agoYou might want to give Emblem a shot. It's similar to HAML or Jade but compiles to Ember/Handlebars-compatible templates: http://emblemjs.com/ http://emblemjs.com/
- jlongster 13y agoDo they provide some kind of spec/API for other engines to support it? That would be a killer feature.
- chaddeshon 13y agoEveryone is telling you ways to get around this, but IMO, if you aren't using Angular templates, then you really aren't using Angular. ng-repeat, and other powerful directives are what's great about Angular. Instead of writing code to loop through something, you declare that it should be repeated. Templates are much easier to read this way. Directives change you way you view your markup. Instead of writing a script that generates the markup you want, you are using a new, more powerful markup language that knows about repeated elements (among other things). And when the data changes, the webpage just updates, with no thought required by you. Recently, I have started using Firebase, which makes this even more powerful (any realtime updating database library would do the same). I just have to say where in Firebase I want to fetch the data from, and where that data goes in the template. From then on, my webpage stays up to date as the data in the database changes (regardless of who changes it).
- ww520 13y agoTry use Knockout.js. I also don't like the heavy weight tools like Bootstrap/Ember/Angular with their my-way-or-the-highway approach. Knockout.js does bidirectional two-way view-model binding and other MVVM goodness without insisting you have to abandon other tools. You can use other template engine easily.
- encoderer 13y agoI can only assume you've never actually used Backbone (Which I also assume is what you meant when you said 'bootstrap'). It's neither heavy or "my way or the highway." Knockout is great, but the two-way bindings do come with a non-trivial performance impact.
- deleted 13y ago[deleted]
- jacques_chester 13y agoI switched from Knockout to AngularJS. Knockout basically thoroughly entangles itself with my model -- I have to wrap my attributes in ko.computed() or ko.observable(). That makes unit testing messier and leaves me constantly trying to remember what is left as .dataAtttribute and what's been transformed into .dataAttribute(). I have to declare the bindings in Angular also, but after that it largely leaves my code alone. I shaved about 10% off my model code when I switched.
- chrisdew 13y agoI also switched from Knockout.js to AngularJS - my code's so much cleaner now, without having to wrap my model in functions.