0

I want to use angularjs in clojure luminus templates. below is my code in luminus.

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
    <div ng-app="">
      <p>Name : <input type="text" ng-model="name"></p>
      <h1>Hello {{name}}</h1>
    </div>

but not getting {{name}} value. please help me how to solve this issue.thanks in advance!

Sankar
  • 6,908
  • 2
  • 30
  • 53

1 Answers1

1

By default luminus is using Selmer template system. Selmer - gives you an option to redefine :tag-open :tag-close :filter-open :filter-close tags.

So if you change your render function to be something like this:

(defn render
  "renders the HTML template located relative to resources/templates"
  [template & [params]]
  (content-type
 (ok
  (parser/render-file
    template
    (assoc params
      :page template
      :csrf-token *anti-forgery-token*
      :servlet-context *app-context*) {:tag-open \[ :tag-close \] :filter-open \[ :filter-close \[}))
"text/html; charset=utf-8"))

You will be able to use angular tags, but you will have to replace all Selmer tags with [% %]. Also, you can use what ever you want as open/close tag. Foe example < and >

r00tt
  • 257
  • 3
  • 18