ericf / express-handlebars

A Handlebars view engine for Express which doesn't suck.
BSD 3-Clause "New" or "Revised" License
2.31k stars 384 forks source link

AngularJS - just a FYI #85

Closed markbarton closed 9 years ago

markbarton commented 10 years ago

Just a quick note in case anyone else was trying to combine handlebars templates with AngularJS client side.

I couldn't find anywhere within the Handlebars configuration to change the delimiters from {{ }} so I could include AngularJS code so to solve this problem I modified my AngularJS code to use a different delimiter:

//This allows angular binding inside a handlebars template
function handlebarsBinding($interpolateProvider) {
    $interpolateProvider.startSymbol('{[{').endSymbol('}]}');
}
angular.config(handlebarsBinding)
ericf commented 10 years ago

@markbarton thanks for the info. I wonder if I should open up this project's Wiki and you could put this info in there. What do you think?

markbarton commented 10 years ago

@ericf What ever you prefer - I don't mind adding it if it helps someone else.

redben commented 9 years ago

You could also just escape the delimiter \{{ngExpression}}. It works for me :

<h2>{{thisIsForHandleBars}}</h2>
<p>\{{thisIsForAngular}}</p>
marksyzm commented 9 years ago

You could also put the HTML files in the public directory, and set it up so you use the .html extension. That way you can use them in both server and client side code.

ericf commented 9 years ago

Closing this since it will show up when someone searches "Angular" in this repo.

nicholaswmin commented 5 years ago

@ericf Is it possible to have the Handlebars delimiter configurable? i.e use %% instead of {{.

Remembering to escape the delimiter every time is error prone but on the other hand handlebars.js doesn't seem to support it, so I doubt this project ever will.