Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
114
rated 0 times [  115] [ 1]  / answers: 1 / hits: 32275  / 10 Years ago, mon, august 18, 2014, 12:00:00

Background



I am currently building a website that uses NodeJS for the server, Express Handlebars(Just Handlebars but server side) , and hopefully AngularJS for some client side stuff.






The Problem



AngularJS and Handlebars use the same syntax for templating

{{foo}}

This causes a problem where AngularJS code will be interpreted by Express Handlebars first, which will then throw an error because the data it is trying to pull only exists in Angular not Node.






The Question



Is there a way to get AngularJS and Express Handlebars to work together?






Possible Solutions




  • Change the syntax of AngularJS


    • I was looking at BackboneJS and it looks like it is possible to change the syntax. There could possibly be something similar is AngularJS.


  • Create a ng helper in Express Handlebars.


    • It would just return its un-parsed content. However I couldn't figure out how to do this.



More From » node.js

 Answers
16

Your first solution is possible, AngularJS allow to change the start/end symbols of text interpolation like this:



appModule.config(function($interpolateProvider) {
$interpolateProvider.startSymbol('{[{');
$interpolateProvider.endSymbol('}]}');
});


Then you could use it in your template:



<div>{[{message}]}</div>


Also see: $interpolateProvider documentation



Hope this helps.


[#69745] Thursday, August 14, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
isham

Total Points: 69
Total Questions: 86
Total Answers: 86

Location: Anguilla
Member since Sun, Jan 29, 2023
1 Year ago
;