1

I am working on an angular app, where I need to display some angular expression in this form:

{{"Hello," name}}

In Hiccup, {} have a special meaning, and is used for attributes, how to use it for angular syntax ?

Amogh Talpallikar
  • 12,084
  • 13
  • 79
  • 135

3 Answers3

7

From the point of view of Hiccup, this will be one of the literal parts of the output, passed as a string:

(hiccup.core/html [:p "{{\"Hello,\" name}}"])
;= "<p>{{\"Hello,\" name}}</p>"

(hiccup.core/html [:p {:class "{{foo}}"}])
;= "<p class=\"{{foo}}\" />"

So, there is no clash, because the {} of Clojure syntax and the {} of Angular's default interpolation markers occur on different "levels" in the source (Angular's markers being written inside strings).

Michał Marczyk
  • 83,634
  • 13
  • 201
  • 212
2

Do not know hiccup, but in Angular with $interpolateProvider you can change startSymbol (normally {{) and endSymbol (normally }}) to whatever you want.

artur grzesiak
  • 20,230
  • 5
  • 46
  • 56
0

You can use the $interpolateProvider in your config to change the default angular's templating symbols.

musically_ut
  • 34,028
  • 8
  • 94
  • 106